Cron Job Not Running?


#1

Hi All,

I’ve set up a cron job to update a MySQL table. I’m pretty sure I’ve got the path set up correctly:

/usr/local/php5/bin/php /home/myuser/example.com/updatemysql.php

Yet I get no results whatsoever: no email, and no change to the table.
The shell user I’m using with this has extra security checked, but still no results. I’m sure that the php file works properly as I’ve tested it separately.
Any ideas?

Thanks!


#2

I personally never rely on email from the cron mechanism itself, in fact I make sure there is no email generated through cron.

If you want to see if in fact your php is running you should add some log file generation to it. something like:

$fp = fopen($logfile, "a"); 
fputs($fp, $now . "," . $newdata[$offset1] . "," . $newdata[$offset2] . "," . $newdata[$offset3] . "," . $newdata[$offset4] . "," . $newdata[$offset5] . "," . $status);
fclose($fp); 

of course you would need to modify this to write variables that are meaningful for you and your script. also make sure that you define $logfile. and finally make sure you deal with clearing the logfile somehow as this snippet opens the file in append mode, meaning the file will continue to grow theoretically forever. An alternative might be to change to $fp = fopen($logfile, “w”); which would overwrite the log each time, meaning only the last run info would be included.


#3

When you say tested separately do you mean in the shell from /home/myuser ? So from /home/myuser php domain.tld/cron.php works, you’re table is updated?

Does it produce any output on success/failure? If not you won’t get any email from cron.

Jw