Home > Article > Backend Development > 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!