Thứ sáu, 11/04/2014, 11:08
For some reasons, crontab on my server doesn't run correctly, this is the cron log:
And this is my crontab content:
The Carriage Return ^M is my trouble. Some searching related to this issue:
http://forums.debian.net/viewtopic.php?f=30&t=75239
http://www.cyberciti.biz/faq/sed-remove-m-and-line-feeds-under-unix-linux-bsd-appleosx/
What I need to do is remove all Carriage Return on my crontab content.
Now, I can see the Carriage Return ^M no longer appear in CRON log:
Mã:
# grep CRON /var/log/syslog
Apr 11 10:36:01 uxvn2500 /USR/SBIN/CRON[12241]: (root) CMD (/root/backup.sh^M)
Apr 11 11:36:01 uxvn2500 /USR/SBIN/CRON[12241]: (root) CMD (/root/backup.sh^M)
And this is my crontab content:
Mã:
# m h dom mon dow command
59 0 * * 2-6 /root/backup.sh
The Carriage Return ^M is my trouble. Some searching related to this issue:
http://forums.debian.net/viewtopic.php?f=30&t=75239
http://www.cyberciti.biz/faq/sed-remove-m-and-line-feeds-under-unix-linux-bsd-appleosx/
What I need to do is remove all Carriage Return on my crontab content.
Mã:
cd /var/spool/cron/crontabs/
sed -e 's/^M//g' root > root.bak
mv root root.bak2
mv root.bak root
rm root.bak2
/etc/init.d/cron restart
Now, I can see the Carriage Return ^M no longer appear in CRON log:
Mã:
# grep CRON /var/log/syslog
Apr 11 13:36:01 uxvn2500 /USR/SBIN/CRON[12241]: (root) CMD (/root/backup.sh)
Apr 11 14:36:01 uxvn2500 /USR/SBIN/CRON[12241]: (root) CMD (/root/backup.sh)