In recent weeks I have seen this type of error many times on my debian 6 servers.
I have seen different exit status, 1, 2, 25, 255
Errors when running cron:
grandchild #10010 failed with exit status 2: 1 Time(s)
grandchild #10042 failed with exit status 2: 1 Time(s)
grandchild #10062 failed with exit status 2: 1 Time(s)
grandchild #10080 failed with exit status 2: 1 Time(s)
or
Errors when running cron:
grandchild #23015 failed with exit status 25: 1 Time(s)
grandchild #23115 failed with exit status 25: 1 Time(s)
grandchild #23223 failed with exit status 25: 1 Time(s)
grandchild #23319 failed with exit status 25: 1 Time(s)
grandchild #23432 failed with exit status 25: 1 Time(s)
grandchild #23510 failed with exit status 25: 1 Time(s)
looking at syslog it looks like this:
Mar 6 06:41:01 myhost /USR/SBIN/CRON[10548]: (www-data) CMD (cd /home/httpd/cgi/inst && /usr/bin/perl /home/httpd/cgi/inst/scheduler.cgi > /dev/null
Mar 6 06:41:01 myhost /USR/SBIN/CRON[10546]: (CRON) error (grandchild #10548 failed with exit status 2)
I have seen this on many servers, with different cronjobs, and I have not yet found out what is going on. so, I have two questions:
- the exit status codes, what do they mean? (1, 2, 25 or 255).
- what can I do to test this further? have anyone seen this before?
note: yes I have googled this, but have not found any solution that fits my case.
some of these cron jobs gives error like this every time, others do this only occationally.
the jobs are not all the same, but they would look something like this:
*/1 * * * * www-data cd /home/httpd/sites/cust/cgi/ && perl /home/httpd/sites/cust/mysoft/core/bin/scheduler.pl >> /home/httpd/sites/cyst/logs/scheduler_cron.log 2>&1
let me know if there is any more information I can give you.
Try creating script files for your tasks in
/usr/local
or/opt
and call those with cron.From the exitcodes, it seems likely that you managed to create invalid commands in
crontab
. Some shell builtins (cd, source, etc.) may not be available. I prefer creating scripts for more complex commands to be run by cron. That makes them easier to test too.E.g. for the line you posted:
/usr/local/sample-task.sh
reads as follows:Don't forget to run
chmod +x /usr/local/sample-task.sh
.Run this manually first (
sudo -u www-data /usr/local/sample-task.sh
) to check that it works, then let cron start it.