Unix 带有日期后缀的cron命令?
在命令行中,我能够做到Unix 带有日期后缀的cron命令?,unix,cron,crontab,Unix,Cron,Crontab,在命令行中,我能够做到 cp htlog.out测试。$(日期'+%m%d%Y') 但当我试着这样做时: 37 17 * * 1-5 cd the/dir && cp htlog.out test.$(date "+%m%d%Y") 它失败,来自CRON守护进程的消息如下: /bin/sh: -c: line 0: unexpected EOF while looking for matching `"' /bin/sh: -c: line 1: syntax error: u
cp htlog.out测试。$(日期'+%m%d%Y')
但当我试着这样做时:
37 17 * * 1-5 cd the/dir && cp htlog.out test.$(date "+%m%d%Y")
它失败,来自CRON守护进程的消息如下:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
我在命令后面有端点。crontab条目有什么问题?
crontab
中的%
具有特殊含义,应该反斜杠,因此:
从man 5 crontab
:
命令中的“%”字符,除非用反斜杠转义
*(),将更改为换行符,并且第一个%之后的所有数据将作为标准输入发送到命令
37 17 * * 1-5 cd the/dir && cp htlog.out test.$(date "+\%m\%d\%Y")