在最近几周里,我在debian 6服务器上多次看到这种types的错误。
我看到了不同的退出状态,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)
要么
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)
看着syslog看起来像这样:
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)
我在许多服务器上看到过这个,有不同的cronjobs,我还没有发现是怎么回事。 所以,我有两个问题:
注意:是的,我已经使用了这个,但没有find任何适合我的情况的解决scheme。
这些cron作业中的一部分每次都会出现这样的错误,其他的只是偶尔发生。
工作并不完全相同,但他们看起来像这样:
*/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
让我知道,如果有更多的信息,我可以给你。
尝试在/usr/local或/opt为您的任务创build脚本文件,然后使用cron调用这些脚本文件。
从exitcodes中 ,你似乎可以设法在crontab创build无效的命令。 一些shell内置(CD,源代码等)可能不可用。 我更喜欢为cron运行更复杂的命令创build脚本。 这使他们更容易testing。
例如,您发布的行:
*/1 * * * * www-data /usr/local/sample-task.sh
/usr/local/sample-task.sh内容如下:
#!/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
不要忘记运行chmod +x /usr/local/sample-task.sh 。
首先手工运行( sudo -u www-data /usr/local/sample-task.sh )来检查它是否工作,然后让cron启动它。