Cron jobs and random times, within given hours

后端 未结 12 2306
甜味超标
甜味超标 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:24

    So I'm using the following to run a command between 1AM and 330AM

    0 1 * * * perl -le 'sleep rand 9000' && *command goes here*
    

    That has been taking care of my random needs for me. That's 9000 seconds == 150 minutes == 2.5 hours

提交回复
热议问题