Cron jobs and random times, within given hours

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

    You can try with this example to use random times before execute command:

    #!/bin/bash
    # start time
    date +"%H:%M:%S"
    
    # sleep for 5 seconds
    sleep $(shuf -i 1-25 -n 1)
    # end time
    date +"%H:%M:%S"
    

提交回复
热议问题