Append current date to the filename via Cron?

后端 未结 4 1483
陌清茗
陌清茗 2020-12-09 07:12

I\'ve created a Cron task at my webhost to daily backup my database and I would like it to append the current date to the filename.

My Cron job looks like this

4条回答
  •  天涯浪人
    2020-12-09 08:16

    I need to create a new log file every time command is executed. So every day I should have a log like this /home/me/Logs/power_20151230.log The crontab line that I use is this:

    00 8 * * * /home/me/power.py ON >> /home/me/Logs/power\_`date +20\%y\%m\%d`
    

    Note the underscore character must be escaped too.

提交回复
热议问题