bash CRONTAB 语法错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7068759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 00:36:11  来源:igfitidea点击:

CRONTAB syntax error

bashubuntucronsyntax-errorcrontab

提问by DocWiki

Herer is my CRONTAB file (Ubuntu 10.10):

这是我的 CRONTAB 文件(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!

但我不确定出了什么问题。非常感谢!

回答by brightlancer

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

Cron 需要转义 % 符号 - http://www.hcidata.info/crontab.htm

Try it with a backslash:

用反斜杠试试:

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