我需要一个在php中可以自行执行而不需要cron帮助的函数。我已经想出了以下代码,它对我很有效,但由于它是一个无限循环,会给我的服务器或脚本带来问题吗?如果有问题,你能给我一些建议或替代方案吗?谢谢。
$interval=60; //minutes
set_time_limit(0);
while (1){
$now=time();
#do the routine job, trigger a php function and what not.
sleep($interval*60-(time()-$now));
}