Home  >  Article  >  Backend Development  >  (转)php步履的定时任务

(转)php步履的定时任务

WBOY
WBOYOriginal
2016-06-13 13:04:42692browse

(转)php脚步的定时任务
ignore_user_abort(); //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行.
set_time_limit(0); // 执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无限制的执行下去
$interval=60*1; // 每隔5分钟运行
do{
$fp = fopen('c:\\test.txt','a');
fwrite($fp,'test');
fclose($fp);
sleep($interval); // 等待5分钟
}while(true);
?>


当然,有个弊端,那就是还是无办法指定某个时间点,还是要靠LINUX的计划任务吧

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn