cron - 运行cron作业会在寻找匹配的 ``'时产生意外的EOF错误

标签 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 of file

你能帮我如何避免它们吗?提前非常感谢您!

最佳答案

您必须转义%字符。 man 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.

关于cron - 运行cron作业会在寻找匹配的 ``'时产生意外的EOF错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11168544/

相关文章:

cron - 如何检查Macbook Lid是否通过终端关闭?

linux - 无法获得正确的 cron 作业计时

php - 使用 cron 作业执行 PHP AJAX 调用

cron - crontab 星期几和月份必须同时匹配吗?

google-app-engine - Google Analytics API 使用哪个时区?

linux - crontab/shellscript 帮助

php - Cron.yaml 没有创建重复发生的任务

linux - 如何在周日每周运行 crontab 作业

php - 5 小时后终止进程的 cron 作业

node.js - 动态更新nodejs cronjob周期