D
D
Damnedest2011-08-19 09:42:54
Message Queues
Damnedest, 2011-08-19 09:42:54

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

7 answer(s)
S
slik, 2011-08-19
@slik

If you do not find a solution for php, then look towards the node.js kue package, there is a json api.

K
Kindman, 2011-08-19
@Kindman

You can add tasks from PHP to cron or scheduler

R
Roman, 2011-08-19
@lampa

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.

A
AnViar, 2011-08-19
@AnViar

1. cron runs with an accuracy of up to a minute
2. sleep in the script allows you to increase the accuracy to seconds.

A
Anatoly, 2011-08-19
@taliban

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,

P
phasma, 2011-08-19
@phasma

something like:
* * * * * sleep ;

B
BasilioCat, 2011-08-19
@BasilioCat

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 question

Ask a Question

731 491 924 answers to any question