- 论坛徽章:
- 0
|
编辑完cronfile以后,使用
$crontab cronfile
马上就会收到一封系统邮件,大致内容如下:
Subject:Your crontab file has an error in it
Your "crontab" on xxx
unexpected end of line
This entry has been ignored.
反复检查我的cronfile,并没有发现错误,而且其中定义的定时任务全都正常运行
虽然不影响使用,毕竟感觉不爽,于是google了一把,发现有同样问题的远不止我一个
半小时后,终于有了收获:
原来是cronfile中的空行在作怪:
通常情况下,为了美观、可读性,在cronfile中都会留有一些空行,注释等内容例如:
#task 1
* * * * * xxxxxxxxxxxxxx
#task 2
* * * * * xxxxxxxxxxxxxx
#task n
正式这些段与段之间的空行被crontab认为是一个error,最简单的办法是删掉这些空行,但是如果非要保持美观,可以把这些空行以#开头,就可以避免出现error.
修改后的cronfile如下:
#task 1
* * * * * xxxxxxxxxxxxxx
#
#task 2
* * * * * xxxxxxxxxxxxxx
#
#task n
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/12767/showart_89569.html |
|