How to implement simple scheduled task execution in php, php execution task_PHP tutorial

WBOY
Release: 2016-07-13 10:06:17
Original
959 people have browsed it

How to implement simple scheduled execution tasks in php, php execution tasks

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:

<&#63;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);
&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/959885.htmlTechArticleHow to implement simple timed execution tasks in php, php execution tasks This article describes the implementation method of simple timed execution tasks in php . Share it with everyone for your reference. The specific implementation method is as follows...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template