Cron jobs and random times, within given hours

后端 未结 12 2323
甜味超标
甜味超标 2020-11-27 11:02

I need the ability to run a PHP script 20 times a day at completely random times. I also want it to run only between 9am - 11pm.

I\'m familiar with creating cron job

12条回答
  •  猫巷女王i
    2020-11-27 11:24

    Cron offers a RANDOM_DELAY variable. See crontab(5) for details.

    The RANDOM_DELAY variable allows delaying job startups by random amount of minutes with upper limit specified by the variable.

    This is seen commonly in anacron jobs, but also can be useful in a crontab.

    You might need to be careful with this if you have some jobs that run at fine (minute) granularity and others that are coarse.

提交回复
热议问题