Answer the question
In order to leave comments, you need to log in
Running tasks accurate to the second?
Are there ready-made solutions for creating an event queue that will allow you to specify the execution time of an event with an accuracy of up to a second? It is also very important that there is a client for PHP.
Answer the question
In order to leave comments, you need to log in
If you do not find a solution for php, then look towards the node.js kue package, there is a json api.
I did something like this: a function in an endless loop, every second I check the database, if there is something, then I execute and delete the row from the database.
1. cron runs with an accuracy of up to a minute
2. sleep in the script allows you to increase the accuracy to seconds.
How do you want to determine the existence of tasks without checking their existence? If they appear in the database, then you need to look at the new tasks in the database.
As an option, you can watch file changes (size / access date) with the desired table, if the table is in myisam, then each table is stored separately. As a result, if tasks appeared in it, then the access date and size will increase,
if I understood the initial data correctly, then you need two things - a queue server and a clock =)
I recommend beanstalkd and the following scheme of work
- the server (application that processes tasks) is ALWAYS running. It listens to the queue in beanstalkd waiting for the task
- the client queues the task with the execution time
- the server forks when the task is received, the child process waits for the time specified in the task, and starts the task for execution
- after the task is completed, it is removed from the queue. If the server process dies prematurely, jobs will fall back into the beanstalkd queue
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question