thebiglebowski11
thebiglebowski11

Reputation: 1461

cronjob calling a php function not responding

I have a Cronjob which calls a php script. The cronjob is executing because I have it set to send me an email when it does. The php script works properly when executed manually. I believe it may have something to do with the permissions, but I am not sure how to check if that's the case. I am using godaddy.

Here is the php script:

$dayOfWeek = date('w');

if($dayOfWeek == 1) $xml = file_get_contents('http://xxxxx.com/mon.xml');
if($dayOfWeek == 2) $xml = file_get_contents('http://xxxxx.com/tues.xml');
if($dayOfWeek == 3) $xml = file_get_contents('http://xxxxx.com/wed.xml');
if($dayOfWeek == 4) $xml = file_get_contents('http://xxxxx.com/thurs.xml');
if($dayOfWeek == 5) $xml = file_get_contents('http://xxxxx.com/fri.xml');
if($dayOfWeek == 6) $xml = file_get_contents('http://xxxxx.com/sat.xml');
if($dayOfWeek == 7) $xml = file_get_contents('http://xxxxx.com/sun.xml');

file_put_contents('Bars.xml', $xml);

mysql_connect("xxxx.hostedresource.com", "user", "userpw") or die(mysql_error());   
mysql_select_db("dbname") or die(mysql_error());

mysql_query("UPDATE mytable SET isWorking='0' WHERE isWorking='1'") or die(mysql_error());  

I am receiving the following error message:

   <br />
    <b>Warning</b>:  file_get_contents(http://xxxxxx.com/fri.xml) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: 
HTTP request failed! HTTP/1.0 403 Forbidden
     in <b>/home/content/77/8761477/html/refreshXML.php</b> on line <b>8</b><br />

Any suggestions?

Thanks

Upvotes: 0

Views: 591

Answers (1)

gwdp
gwdp

Reputation: 1212

Why it's failing ? Check on /var/log/cron for better error output...

Check if your PHP command is reachable from cronjob. I would try to call php as /usr/bin/php not only php command itself.

Hope it helps

Upvotes: 1

Related Questions