How can cron output to a new log file based on date?

后端 未结 1 1926
轻奢々
轻奢々 2020-12-22 03:29

I\'d like to log cron output to a dated file — /tmp/log/cron-2014-12-17.log

$ mkdir /tmp/log
$ chmod 777 /tmp/log
$ ls -lah /tmp/log
drwxrwxrwx          


        
相关标签:
1条回答
  • 2020-12-22 03:51

    This will fix your issue:

    0 0 * * * /some/path/to/a/file.php >> /tmp/log/cron-`date +\%F`.log 2>&1
    
    0 讨论(0)
提交回复
热议问题