CRONTAB syntax error

帅比萌擦擦* 提交于 2019-12-03 14:34:01

问题


Herer is my CRONTAB file (Ubuntu 10.10):

57 1 * * 2-6  ET=`date --date 'yesterday'+%Y%m%d`;echo $ET

Even The syntax color indicate that something is wrong. and there is this error:

Subject: Cron <root> ET=`date --date 'yesterday' + (failed)
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>

/bin/sh: Syntax error: EOF in backquote substitution

But I am not sure whats wrong. Thanks a lot!


回答1:


Cron needs to escape the % sign - http://www.hcidata.info/crontab.htm

Try it with a backslash:

57 1 * * 2-6  ET=`date --date 'yesterday' +\%Y\%m\%d`;echo $ET


来源:https://stackoverflow.com/questions/7068759/crontab-syntax-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!