llokely
llokely

Reputation: 93

Random cron run

I have one php script which I would like to run few times an hour at random time. How could I do it?

Upvotes: 2

Views: 562

Answers (2)

JJJ
JJJ

Reputation: 33163

Have Cron run the script every minute and put something like this at the start of the PHP script:

// stop the script approx. 9 out of 10 times
if( rand( 1, 10 ) != 1 ) {
    die();
}

Upvotes: 1

Sabeen Malik
Sabeen Malik

Reputation: 10880

Have the cron set to run the script every minute or 5 mins or whatever and place the random timing check in the top of the script itself.

Upvotes: 0

Related Questions