linux - 为什么我在为我的 cron 作业寻找匹配的 `' 时收到意外的 EOF?

标签 linux bash shell

/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/

相关文章:

linux - 删除文件名中的前 4 个字母和后 4 个字母

linux - 为什么Linux中有些文件名以数字开头?

Bash- 在没有 shell 解释参数扩展字符的情况下传递输入

linux - 使用 awk 或 sed 基于公共(public)列组合两个 csv 文件

regex - Bash 脚本 : Append parent directories to filenames

linux - 如何在 bash 的 while 循环中选择一个选项

python - 无法使用 python3 从 apache2 服务器运行 bash 脚本?

linux - 如何计算gitlab中两次提交之间更改的行数?

linux - 从本地仓库安装 postgresql——为什么无法从仓库下载?

arrays - bash 脚本,在目录中创建所有文件的数组