I have a php script that is run once a minute. The script runs a second script, then sleeps for a given amount of time.
Right now the time is static. 20 seconds each time.
What I need is to randomize the amount of time it sleeps. It can be more than a total of 60 seconds, but not less.
So here is what i have now.
$sleep1 = rand(2,18);
$sleep2 = rand(2,18);
$sleep3 = rand(2,18);
$sleep4 = rand(2,18);
if $sleep1 + $sleep2 + $sleep3 + $sleep4 <= 60 ?
I need to add up all the $sleep variables, and then determine if the total is less than 60. If it is, I need to increase the value of one or more of the variables to make up the difference.
If you can have more than, or do not need exactly 4 $sleep_ variables:
Gives you something like: