dougaxing8673 2018-10-12 20:45
浏览 131
已采纳

Cron作业根据时间重命名媒体文件

I have a media file that I would like to present to users on my site based on time of day. I would like to use a CRON job to rename the files so that I can easily manage the media being displayed.

i.e.

default media displayed on site is default.mp4

default.mp4 renamed to 0.mp4 at 03:00 and 1.mp4 is renamed to default.mp4

default.mp4 renamed to 1.mp4 at 03:00 and 2.mp4 renamed to default.mp4

default.mp4 renamed to 2.mp4 at 03:00 and 3.mp4 renamed to default.mp4

and so on....

what is the CRON job syntax for this?

  • 写回答

1条回答 默认 最新

  • drelgkxl93433 2018-10-12 21:03
    关注

    To run a script at 03:00 every day:

    0 3 * * * *
    

    Though I'm guessing you copy-pasted those lines & neglected to update the time, as what you're asking will cause multiple files to be renamed default.mp4 at the same time.

    Here's a good site for explaining CRON syntax: http://www.nncron.ru/help/EN/working/cron-format.htm

    This is a good one for testing: https://crontab.guru/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?