php ignore_user_abort()实现计划(定时执行)任务功能
<?php ignore_user_abort(TRUE); //关掉浏览器,PHP脚本也可以继续执行. set_time_limit(300); // 通过set_time_limit(0)可以让程序无限制的执行下去 ,这里最大设置了300秒 $interval=10; // 每10秒运行 $stop=1; do{ if($stop==10) break; //第十次停止运行 //这里是你要执行的代码 $rs = file_put_contents('log.txt',$stop."\r\n", FILE_APPEND); //日志记录 $stop++; sleep($interval); // 等待10分钟 }while(true);