Home  >  Article  >  Backend Development  >  How to implement scheduled tasks in php

How to implement scheduled tasks in php

Guanhui
GuanhuiOriginal
2020-05-07 14:39:553609browse

How to implement scheduled tasks in php

How to implement scheduled tasks in php

First use the "ignore_user_abort()" function to close the browser and allow the php script to continue executing ;

ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.

Then use "set_time_limit(0)" to allow the program to execute without limit;

set_time_limit(3000);// 通过set_time_limit(0)可以让程序无限制的执行下去

Finally, write a timed loop to execute the business logic.

do{
   //这里写业务逻辑
    sleep(5);// 等待5s   
} while (true);

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of How to implement scheduled tasks in php. For more information, please follow other related articles on the PHP Chinese website!

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