/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
这是我的 Cron 作业:
*/1 * * * * aide --check | echo "Start timestamp: `date +'%Y-%m-%d %H:%M:%S'`" > /var/log/aide/aide2.log
最佳答案
这是因为 %
符号在 crontab 中被特殊处理。那些,如果需要的话,必须用 \
进行转义。这是来自联机帮助页的引述:
The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. 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. There is no way to split a single command line onto multiple lines, like the shell's trailing "\".
但是,正如 wRAR 指出的那样,该管道没有任何意义。你可能想要 ||
而不是 |
。
关于linux - 为什么我在为我的 cron 作业寻找匹配的 `' 时收到意外的 EOF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36057435/