• Home
  • Store
  • Forum
  • Blog

XTDV Forum
Đăng nhập Đăng ký
Đăng nhập XTDV Forum

XTDV Forum › International zone (English only) › SERVER
Crontab does not run correctly ^M

Thread tools
Crontab does not run correctly ^M
xtdv
Điều hành cao cấp
Bài viết: 504
5 Likes
   
#1
Thứ sáu, 11/04/2014, 11:08
For some reasons, crontab on my server doesn't run correctly, this is the 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)


Trả lời
Send thread to a friend
Send thread to a friend
Send thread to a friend
Send thread to a friend



Những người đang xem chủ đề này:   1 khách


  •  Trở lên trên
  •  Liên hệ
  •   XTDV Group
  • Bản thu gọn (Lưu trữ)
© Rush Crafted with ❤ by iAndrew
Chạy trên nền tảng MyBB, © 2002-2021 MyBB Group.
Chế độ thứ tự
Chế độ đề tài
Xem phiên bản để in
Theo dõi đề tài này
Thêm bình chọn
Send thread to a friend