随机cron运行

时间:2010-11-21 13:39:51

标签: random cron

我有一个PHP脚本,我想在随机时间每小时运行几次。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

让Cron每分钟运行一次脚本,并在PHP脚本的开头添加类似的内容:

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

答案 1 :(得分:0)

让cron设置为每分钟或5分钟或其他任何时间运行脚本,并将随机时间检查放在脚本本身的顶部。

相关问题