Detecting why a Cron task is cutting off

Associate
Joined
19 Jun 2003
Posts
1,680
Location
West Yorks, UK
Hi all,
I have a PHP script that I run as a Cron task every day, at 8am (on a Ubuntu 7.04 server). It is fairly simple, and basically does the following:

1) Grab a list of users from MySQL
2) Loop through, executing a "du -hs" shell command on their home folder, and inserts the data back into MySQL

At the moment, there are only 13 users to go through. For some reason, the Cron task stops on user 6 every day. If i run the script manually, it works fine, with no complaints.

Is there any easy why to check why this is happening when run from the Cron?

Cheers,
Matt
 
What does the entry in your crontab point to?

php /path/to/script.php

or

wget [.....] http://host.com/script.php

You can also redirect stdout and stderr by adding something like '>/dev/null 2>&1' to the end of the crontab entry, which in this case redirects both to /dev/null (supresses all info/warnings etc - try redirecting them to log files to find out what's happening).
 
Hi,
I've altered the crontab to use the line stdout stuff, so it now looks like this:

Code:
30 8 * * * root php /scripts/reporting/admin/log_folder_size_to_DB.php > /scripts/reporting/admin/folder_size.log 2>&1

Does that look OK?

Matt
 
That was how my cron looked anyway, except for the error logging bit. Odd thing is, as soon as I added the error logging to the end, the cron started working fine, and got all the way to the end...

Weird :confused:
 
Back
Top Bottom