S
S
stanlee2015-10-15 11:46:28
PHP
stanlee, 2015-10-15 11:46:28

What is the best way to organize the execution of scripts on a schedule?

I have a php project.
There are tasks that need to be performed in the background, at a specified time in the future, or cyclically on a schedule.
Cron can easily deal with cyclic tasks, but what about one-time tasks?
I considered rabbitmq, but googled that it has a sequential workflow in a queue or create a bunch of queues.
Until I understand this is what I need or not, therefore, I ask the audience for help) Maybe someone has a more interesting idea.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
6
65536, 2015-10-15
@65536

create a table in the database with columns: task, runtime
make a script that will select tasks from it with a time less than the current one
and execute
after execution, you can delete the entry if the task was one-time or set the next run time

E
Evgeny Svirsky, 2015-10-15
@e_svirsky

Make another cron job - one that will run the same command every hour (or minute or 10 minutes... whatever you want).
And in this team - get tasks from the database, for example. In the database - pass what needs to be called and from where and what parameters to transfer.
The task is done - the status is changed to done - this task will no longer twitch, or remove the task from the queue from the database.
Tasks have accumulated - crowns have completed them one by one. There are no tasks - cron just checks for the presence of tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question