P
P
Peter Gribanov2017-05-19 17:59:52
linux
Peter Gribanov, 2017-05-19 17:59:52

Are there sensible analogues of the AT task scheduler?

For some time I have been trying to find information on the topic, but so far to no avail.
The task is next.
There is a web application written in PHP and running on a Linux server. Everything is as usual.
The task is that I need to perform some tasks on a schedule. But to perform these tasks not regularly, but once, and I need to manage this through my application.
For example, I have a mechanism for delayed publication of news. The editor creates a news item and specifies the day and time that the news item should be published. Now I check the publication date when selecting, but this is not the best solution.
Knowing the publication date, I just need to run a script at a given time that will publish the news.
It is not reasonable to use cron for these purposes, because it will pull the application idle in 99% of cases. From all that I could dig up, this is the at utility . It seems to do exactly what I need.
Launch planning might look like:

shell_exec('at php news_publisher.php 12345 -t 201710271030');

Everything seems simple, but somehow it seems to me a crutch. I'm not sure if it can be used in combat. Who knows how reliable and stable this solution is? What happens if the server restarts, the schedule remains? What if the server is offline for a while and after starting it turns out that he missed a few tasks. Will he fulfill them?
Maybe there are some more stable and convenient solutions? Or do you need to write your own implementation?
Another problem will be if the editor changes the time of publication of the news. It turns out I have to remove the old task and install a new one. To do this, you will have to store a list of id tasks somewhere.
In general, I have not found a solution yet. Maybe you have some ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Korobkov, 2017-05-19
@BorisKorobkov

cron is a perfectly reasonable solution. It is not necessary to run every minute - every hour or even less often is enough.
Even if it fails, then the load from a single query on indexed fields "publish all unpublished articles that have a publication date already" will be close to zero.

A
Alexey Cheremisin, 2017-05-19
@leahch

I also recommend celery, although it is written in python, there is a PHP client for it
www.celeryproject.org and https://github.com/gjedeer/celery-php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question