PHP 文件定时执行

 PHP 文件定时执行

<?php
namespace app\index\controller;
use	think\Controller;
use	think\Db;
class Index extends Base
{
   public function index()
    {
        $Config=Model("Config");
        ignore_user_abort();//关闭浏览器后,继续执行php代码
        set_time_limit(0);//程序执行时间无限制
        $boo=1;
        $sleep_time = 5;//多长时间执行一次
        $switch = include 'switch.php';
        while($boo){
            //通过更改后台数据达到控制
            $info=$Config->where("cnfname","cnf_time")->find();
            $sleep_time=$info->sleep_time;
            $boo=$info->boo;
            //...
            //执行代码
            //...
            sleep($sleep_time);//等待时间,进行下一次操作。
        }
        exit();
    }
}
?>

点击关注

猜你喜欢

转载自blog.csdn.net/yuzsmc/article/details/82148622