Cron jobs and random times, within given hours

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

    I realize it's an older thread, but I want to add one random-value related thing that I use a lot. Instead of using the $RANDOM variable with a fixed and limited range, I often make arbitrary-range random values in the shell with

    dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -N4 -t u4 -A none
    

    so you can do, for example,

    FULLRANDOM=$(dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -N4 -t u4 -A none)
    

    and overcome some the restrictions that were discussed in this thread.

提交回复
热议问题