PHP定时执行任务的实现

转载:http://www.oschina.net/code/snippet_105076_3962

config.php

<?php
return 1;
?>

cron.php
ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
set_time_limit(0);// 通过set_time_limit(0)可以让程序无限制的执行下去
$interval=60*30;// 每隔半小时运行
do{
$run = include 'config.php';
if(!$run) die('process abort');
 //这里是你要执行的代码 
 sleep($interval);// 等待5分钟
}while(true);



主要改变config.php中return 0就可以实现了控制这个cron,
原文地址:https://www.cnblogs.com/wluomo/p/4118778.html