以下命令在提示符下工作,但不在 crontab 中工作。
grep abc /var/log/messages | grep "`date '+%B %d'`" | mail -s"abc log of `hostname`" shantanu.oak+`hostname`@gmail.com
Run Code Online (Sandbox Code Playgroud)
我需要将它添加到每日 cron 中。
bmk*_*bmk 160
你必须逃离这些%迹象。它们在 crontab 中有特殊的含义:
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.
Run Code Online (Sandbox Code Playgroud)
这不能直接回答您的问题,但我建议您在 /usr/local/bin(或 ~/bin 或任何适当的文件)中创建一个脚本文件,并从 cron 调用它。测试和编辑更容易。
| 归档时间: |
|
| 查看次数: |
38729 次 |
| 最近记录: |