1

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:

  1. the exit status codes, what do they mean? (1, 2, 25 or 255).
  2. 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.

2
  • 1
    What does the log of your Perlscript show for the failed calls? And why do you talk about mysql in your question? I don't see anything mysql-related here. – nlu Mar 12 '15 at 17:03
  • sorry, my comment was in error, this is a cron and perl problem, not directly mysql. – Sverre Mar 16 '15 at 7:27
1

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:

*/1 * * * * www-data /usr/local/sample-task.sh

/usr/local/sample-task.sh reads as follows:

#!/bin/bash
cd /home/httpd/sites/cust/cgi/
/usr/bin/perl /home/httpd/sites/cust/mysoft/core/bin/scheduler.pl >> /home/httpd/sites/cyst/logs/scheduler_cron.log 2>&1

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.

2
  • I have looked at this, but could not fix the problem with this procedure. – Sverre Mar 16 '15 at 7:27
  • @Sverre Run strace and link the output with pastebin or gist. – chicks Sep 21 '15 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.