84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
How to execute a certain program on the server every period of time, please give me some ideas.
Following the voice in heart.
The server crontab sets a scheduled task, and the scheduled task runs the PHP file in CLI mode.
PHP CLI mode documentation: http://php.net/manual/zh/feat... crontab documentation: http://www.cnblogs.com/peida/...
In the comments, I saw someone asking whether it is linux or windows, so I will also talk about the operation method of windows. In the above idea, PHP CLI mode runs php files, this remains unchanged; Scheduled tasks can Use the scheduled tasks that come with windows to execute.
linux
windows
linux crontabSelf-Baidu
crontab, queue, redis, etc. can be combined to achieve scheduled tasks
1.linux crontab
* * * * * command
(minute, hour, day, month, day of week, command to be executed)
2. Message middleware
3. PHP loop hangs
It is recommended to use the first method for simplicity.
The server crontab sets a scheduled task, and the scheduled task runs the PHP file in CLI mode.
PHP CLI mode documentation:
http://php.net/manual/zh/feat...
crontab documentation:
http://www.cnblogs.com/peida/...
Update
In the comments, I saw someone asking whether it is
linux
orwindows
, so I will also talk about the operation method ofwindows
.In the above idea, PHP CLI mode runs php files, this remains unchanged;
Scheduled tasks can Use the scheduled tasks that come with
windows
to execute.linux crontab
Self-Baidu
crontab, queue, redis, etc. can be combined to achieve scheduled tasks
1.linux crontab
(minute, hour, day, month, day of week, command to be executed)
2. Message middleware
3. PHP loop hangs
It is recommended to use the first method for simplicity.