This article mainly share with you the Linux solution PHP Timer problem method code, PHP is often passive execution, the user sends an HTTP request, the server receives the request to execute, he is very difficult to take the initiative to do something. For a language with no timers or a weak timer in PHP, the Linux task should be used decisively.
The idea is to plan the task, according to the set time to execute the Curl command, or send an HTTP request, since you PHP like passive, let you passive to the end.
1. Create a scheduled task
[Root@izbp17kcgwxvwveyk6c15dz ~]# crontab-ecrontab:installing new Crontab[root@izbp17kcgwxvwveyk6c15dz ~]# crontab- L1 1 1 * * /phpstudy/mycurl.sh1,11,21,31,41,51 1,2,3,4 1 * * /phpstudy/mycurldepot.sh5,35 * * * * /phpstudy/my Curlautocheck.sh[root@izbp17kcgwxvwveyk6c15dz ~]#
Edit Task Crontab-e
View current Task Crontab-l
Detailed command: Click to open link
2.SH File Curl Command
Curl http://127.0.0.1/autocheck.php
3. Specific business logic
Executing in PHP