The example in this article describes the implementation method of simple scheduled execution of tasks in PHP. Share it with everyone for your reference. The specific implementation method is as follows:
<?php ignore_user_abort(); set_time_limit(0); $interval = 60*5; do{ $url = "http://www.sina.com.cn/"; $ch = curl_init();//创建一个新的curl会话 curl_setopt($ch,CURLOPT,$url);//设置需要抓取的cURL curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); //设置cURL参数,要求结果保存到字符串还是页面(1或真表示保存而不输出) curl_setopt($ch,CURLOPT_TIMEOUT,2);//最大延续2秒 $result = curl_exec($ch);//执行 curl_close($ch);//关闭 sleep($interval);//休息5分钟 }while(true); ?>
I hope this article will be helpful to everyone’s PHP programming design.