I'll quote Naist First of all, you need to be able to use crontab. Yes, if you don't know how to use it, just use Baidu. I won't answer it here. You can write a blog. Then in the command line
It may not be crontab. I used node.js to write a WebSocket that users can schedule by themselves before and hang in the background. When the user sends a request to this WebSocket, the scheduled time is recorded in a cache file (JSON), and then node.js sets its own timer.
If the WebSocket service hangs up, just restart the background script, and the script will reset the scheduled task based on the time recorded in the cached JSON. I can put some code here, the core code is omitted, and some comments are added for reference
For PHP, you can only use crontab to select scheduled tasks, so the shortest training rotation time is 1 second If you want it within 1 second, you have to find another way.
Keywords: shell_exec, php safe mode
shell_exec solves your problem of adding scheduled tasks. The shell_exec function cannot be used when PHP safe mode is turned on.
Scheduled tasks can be stored in MySQL or files, and then use crontab to run mysql or files
Use crontab, such as:
mysql stored procedures can also run scheduled tasks
Use independent scheduled task middleware to manage, user scheduled tasks are not suitable to be placed in crontab
I'll quote Naist
First of all, you need to be able to use crontab. Yes, if you don't know how to use it, just use Baidu. I won't answer it here. You can write a blog.
Then in the command line
After
It may not be crontab. I used
node.js
to write a WebSocket that users can schedule by themselves before and hang in the background. When the user sends a request to this WebSocket, the scheduled time is recorded in a cache file (JSON), and thennode.js
sets its own timer.If the WebSocket service hangs up, just restart the background script, and the script will reset the scheduled task based on the time recorded in the cached JSON. I can put some code here, the core code is omitted, and some comments are added for reference
For PHP, you can only use crontab to select scheduled tasks, so the shortest training rotation time is 1 second
If you want it within 1 second, you have to find another way.