bash -/bin/sh : Syntax error: Unterminated quoted string

标签 bash ubuntu

我正在尝试让一个 cronjob 将输出通过管道传输到指定(文件夹)位置的一个日期文件。

我的 crontab 条目看起来像这样:

* * * * * /some/path/test.sh >> $(date "+/home/oompah/logs/%Y%m%d.test.log")

我不明白的是,当我在控制台输入这个命令时,我得到了正确的字符串:

echo $(date "+/home/oompah/logs/%Y%m%d.test.log")
/home/oompah/logs/20110329.test.log

是什么导致了这个错误,我该如何解决?

bash 版本信息是:

GNU bash,版本 4.1.5(1)-release (x86_64-pc-linux-gnu)

最佳答案

你应该在你的 crontab 中排除百分号:

* * * * * /some/path/test.sh >> $(date "+/home/oompah/logs/\%Y\%m\%d.test.log")

百分号 (%) 在 crontab 中有特殊的含义。它们被解释为换行符。

关于bash -/bin/sh : Syntax error: Unterminated quoted string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5473876/

相关文章:

python - 安装orange2.6 cc1plus时出错: warning: -Wstrict-prototypes’

linux - 不匹配任何东西的 Glob 会扩展到自身,而不是什么都没有

bash - Bash 编译器

bash - 如何从脚本设置 bash 环境变量?

c# ping 类在 monodevelop 中抛出异常

ubuntu - 以用户身份安装 CEDET 1.0pre6,同时保持安装 CEDET 1.0pre4 deb 包

ubuntu - activemq 中的内存限制 (67108864)

c# - 使用 Mono 从 Linux 终端构建 C# 控制台项目

bash - 设置 svn :ignore recursively for a directory structure

regex - posix 扩展正则表达式中的变量扩展