Home  >  Article  >  php教程  >  PHP定时执行任务的实现

PHP定时执行任务的实现

PHP中文网
PHP中文网Original
2016-05-25 17:13:091195browse

用到的函数  ignore_user_abort(),set_time_limit(0),sleep($interval) 
此代码只要运行一次后关闭浏览器即可。 
不知道能程序的性能会不会影响很大! 

ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
set_time_limit(0);// 通过set_time_limit(0)可以让程序无限制的执行下去
$interval=60*30;// 每隔半小时运行
do{
    //这里是你要执行的代码    
    sleep($interval);// 等待5分钟
}while(true);
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
Previous article:PHP和机场三字码的操作Next article:PHP Entity