<?php
/*
* PHP定时执行任务的实现
* Crazy:http://code.zhangyun.org
*/
// 关掉浏览器,PHP脚本也可以继续执行.
ignore_user_abort();
// 把php的30秒执行限制关闭
set_time_limit(0);
// 设置休眠时间,默认为5秒
$sleep_time = 5;
do {
#-- 这里是你要执行的代码
$time = time();
$fp = @fopen('time.txt', 'w');
@fputs($fp, $time, strlen($time));
@fclose($fp);
#-- 执行的代码结束
sleep($sleep_time);
} while(true);
?>