In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how PHP performs tasks regularly, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.
Concrete realization
1. Windows schedule tasks
PHP seldom runs on win servers, and the specific implementation is no longer delved into. The principle of online implementation is probably to write a bat script, and then let the window task add and execute this bat script.
2. Script implementation of linux
The command crontab is mainly used here.
Mode of use:
Crontab filecrontab [- u user] [- u user] {- l |-r |-e}
Description:
Crontab is used to allow users to run programs at fixed times or intervals.
Use crontab to write shell scripts, and then let PHP call shell, which takes advantage of the features of linux, which should not be counted as a feature of PHP's own language.
3. PHP implements regular execution of scheduled tasks.
There are several problems that need to be solved to refresh the browser with php
PHP script execution time limit, default is 30m solution: set_time_limit (), or modify PHP.ini to set max_execution_time time (not recommended)
If the client browser is closed, the program may be forced to terminate. The solution: ignore_user_abort executes normally even if the page is closed.
If the program is running all the time, it is likely to consume a lot of resources, the solution is to use sleep to use the program to sleep for a while, and then execute
Code that is timed by PHP:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.