Cron jobs and random times, within given hours

后端 未结 12 2316
甜味超标
甜味超标 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条回答
  •  长情又很酷
    2020-11-27 11:17

    al-x 's Solution does not work for me since crontab commands are not executed in bash but in sh I guess. What does work is:

    30 8 * * * bash -c "sleep $[RANDOM\%90]m" ; /path/to/script.py
    

提交回复
热议问题