我想为日志文件名中包含当前小时的 cron 脚本创建一个日志文件。这是我尝试使用的命令:
0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log
Run Code Online (Sandbox Code Playgroud)
不幸的是,我在运行时收到此消息:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
Run Code Online (Sandbox Code Playgroud)
我曾尝试date
以各种方式逃避该部分,但运气不佳。是否可以在 crontab 文件中内嵌进行此操作,或者我是否需要创建一个 shell 脚本来执行此操作?