Ubuntu 16.04 中的 2 个 cronjobs 中有 1 个不是 运行 for windows - 由于 cron 中的“日期”扩展

1 of 2 cronjobs not running in Ubuntu 16.04 for windows - due to `date` expansion in cron

我的 crontab 中有两个 cronjobs。第一个作品;第二个没有。具体来说,

40 18 * * * cp /mnt/c/Users/Adrian/pick_of_the_day/daily_winner /mnt/c/Users/Adrian/pick_of_the_day/`date +'%b-%d-winner'` 

无效。

我试过:

- commenting out the first one
- removing the full path for the destination file and checking the default DIR for my user
- using a relative path for the dest file
- looking through 5 other cronjob questions on this site
- looking for the cron log file but it doesn't exist.  Before someone tells me to check syslog, please note it doesn't exist on my installation.
- **I removed the ">>/var/log/cron_output.log 2>&1" and just left the command**

Aviator@AW:/var/log$ ls alternatives.log btmp dpkg.log fsck lxd upstart apt dist-upgrade fontconfig.log lastlog unattended-upgrades wtmp Aviator@AW:/var/log$

35 18,21 * * * /mnt/c/Users/Adrian/pick_of_the_day/winner
40 18 * * * cp /mnt/c/Users/Adrian/pick_of_the_day/daily_winner 
/mnt/c/Users/Adrian/pick_of_the_day/`date +'%b-%d-winner'` >>/var/log/cron_output.log 2>&1

cron 中的 % 个字符需要转义,而在脚本中或直接在 cmd 行中则不需要。

在逃避他们之后,cronjob 运行 如预期的那样。

cp /mnt/c/Users/Adrian/pick_of_the_day/daily_winner /mnt/c/Users/Adrian/pick_of_the_day/$(date +'\%b\%mwinner')

我刚刚找到的相关答案: https://unix.stackexchange.com/questions/29578/how-can-i-execute-date-inside-of-a-cron-tab-job

https://unix.stackexchange.com/questions/252615/why-doesnt-date-f-t-work-in-crontab