时间:2021-07-01 10:21:17 帮助过:32人阅读
本次使用php实现计划任务主要使用了 ignore_user_abort() set_time_limit(0) sleep() 这三个函数。
具体的代码如下:
';
sleep($interval);// 等待5s
}while(true);
//方法2---sleep 定时执行
require_once './curlClass.php';//引入文件
$curl=new httpCurl('www.phpernote.com');//实例化
$stime=$curl->getmicrotime();
for($i=0;$i<=10;$i++){
echo '测试'.time().'
';
sleep($interval);// 等待5s
}
ob_flush();
flush();
$etime=$curl->getmicrotime();
echo '
';
echo round(($etime-stime),4);//程序执行时间
在具体的实现过程中个人感觉PHP定时执行任务的效率并不高,建议关于定时执行任务的工作还是交给shell来做吧,相对来说,这个方法实现的太过勉强,而shell是专业级别的了。
http://www.bkjia.com/PHPjc/779407.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/779407.htmlTechArticle最近由于项目需要定时对远程数据库上做一些处理,这里就需要做一个计划任务样子的东西了。经过努力,终于使用php实现了这个计划任务...