Home >Backend Development >PHP Tutorial >php if automatically perform tasks
There is currently a requirement. The platform assigns tasks to the people below. After clicking Send, if the people below do not reply within five minutes, a text message reminder will be sent. I don’t know if there is a good way. Sleep seems to be unusable and will always stay on the current page. What is required is that after clicking, it will automatically determine whether there is a reply after 5 minutes, or should it be through a scheduled task? When clicked, the scheduled task is triggered, and the specified php script is executed after 5 minutes to determine whether to reply. Is there any simple idea or method?
There is currently a requirement. The platform assigns tasks to the people below. After clicking Send, if the people below do not reply within five minutes, a text message reminder will be sent. I don’t know if there is a good way. Sleep seems to be unusable and will always stay on the current page. What is required is that after clicking, it will automatically determine whether there is a reply after 5 minutes, or should it be through a scheduled task? When clicked, the scheduled task is triggered, and the specified php script is executed after 5 minutes to determine whether to reply. Is there any simple idea or method?
linux crontab.
php is not good at this
You need php socket, please refer to workerman, swoole for details
The poster can use php script to run in the command line.
Here is the answer you want http://m.blog.csdn.net/articl...
If it is a Linux server, it is recommended to use the crontab command
http://blog.csdn.net/xiyuan19...
When you click to send the task, record who it is sent to and the time. If there is a reply, delete the record
Then write a script to check the above record. If the time is greater than or equal to 5 minutes, send a text message
Then use crontab to execute the script regularly
If you insist on using sleep(), it is recommended to add clearstatcache() after sleep()
Use swoole, as mentioned above.