Solve Crontab Job Error.Configuration,Example Script,expression,Solve Problem Linux
Tuesday, December 17
(CRON) error (grandchild #11934 failed with exit status 127)
I solved this cron issue in ubuntu.
========
This cron job line will have error 127 in ubuntu server 11.04.
* * * * * root /bin/date > /var/log/date.txt
May 17 12:34:01 gw1 CRON[11934]: (root) CMD (root /bin/date > /var/log/date.txt)
May 17 12:34:01 gw1 CRON[11932]: (CRON) error (grandchild #11934 failed with exit status 127)
May 17 12:34:01 gw1 CRON[11932]: (CRON) info (No MTA installed, discarding output)
May 17 12:34:01 gw1 CRON[11935]: (root) CMD ( /bin/date > /var/log/date.txt)
========
This cron job line will NOT have error 127 in ubuntu server 11.04.
* * * * * root cd / ; /bin/date > /var/log/date.txt
May 17 12:38:01 gw1 CRON[11961]: (root) CMD (root cd / ; /bin/date > /var/log/date.txt)
May 17 12:38:01 gw1 CRON[11962]: (root) CMD ( cd / ; /bin/date > /var/log/date.txt)
May 17 12:38:01 gw1 CRON[11959]: (CRON) info (No MTA installed, discarding output)
========
The file in /var/log/date.txt generated successfully with this contents.
Tue May 17 12:38:01 HKT 2011
========
It seems the exit code is default to 127 and not set to the command. The added command "cd / ;" or any success command will reset it. Then the actual command can return the exit code properly.
May be somebody should look at the cron or related source code.
========
Also, the command in the cron job line must be in full path. Such as
/bin/date
/bin/run-parts
The script files for run-parts must not have "." . Such as
gw1-dnns-sh
This will not work.
gw1-dnns.sh
========
I found this limitation is ubuntu server 11.04.
http://ubuntuforums.org/showthread.php?t=1760488
0 comments:
Post a Comment