运行cron作业在查找匹配的`';
我可以看出这是“常见”错误,但在我的情况下找不到解决方案 运行Crontab作业时使用:运行cron作业在查找匹配的`';,cron,crontab,cron-task,Cron,Crontab,Cron Task,我可以看出这是“常见”错误,但在我的情况下找不到解决方案 运行Crontab作业时使用: expr `date +%W` % 2 > /dev/null && curl https://mysite.com/myscript 它会导致错误: /bin/sh: -c: line 0: unexpected EOF while looking for matching ``' /bin/sh: -c: line 1: syntax error: unexpected end
expr `date +%W` % 2 > /dev/null && curl https://mysite.com/myscript
它会导致错误:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
你能帮我怎么避开它们吗?提前非常感谢 您必须转义
%
字符<代码>人5 crontab显示:
Percent-signs (%) in the command, unless escaped with backslash (\),
will be changed into newline characters, and all data after the first %
will be sent to the command as standard input.
尝试转义
%
,不要使用反勾号来编码日期
-命令。一定要用$()
将其括起来:
或
这一点知识对我帮助很大。我无法理解为什么
date+%Y-%m-%d\u%H-%m-%S
在脚本中工作得很好,但在(菊花链的crontab)命令行中却没有。谢谢你,丹尼尔!
expr $(date +\%W) % 2 > /dev/null && curl https://mysite.com/myscript
expr $(date +\%W % 2) > /dev/null && curl https://mysite.com/myscript