Schedule a job in Gearman for a specific date and time

五迷三道 提交于 2019-11-29 00:15:05

I have decided to go the at route as originally laid out in my question. For the purpose I have written a little PHP wrapper for the at binary and tested it on Ubuntu. If you are interested it can be found on github: http://github.com/treffynnon/PHP-at-Job-Queue-Wrapper

A rather hacky solution, which would only work well at hourly or daily resolution would be to make the job (function) name contain the date at which you wanted it sent. Then have workers starting in cron every hour or day to register for those jobs.

For example, if you wanted to send an email at 9AM on Monday March 12th 2012, add a job to the queue with a name like email_2012-03-12_09:00. Then have a cron job running hourly, which runs a worker who registers for any jobs matching email_ + current date and hour.

As I say, probably workable, but rather hacky!

UPDATE 1: I saw recently that the docs for gearmand database persistence now mention a field named when_to_run which is an INT, and could potentially hold a unix epoch timestamp. This field doesn't seem to be referenced in the code yet.

Eddie Jaoude

If you are using Zend...

SlmQueue is a job queue abstraction layer. It allows you to easily use job queue systems in a Zend Framework 2 application. Thereby it does not enforce you to specifically use one type of job queue. You can write your code and jobs independent of the underlying system. This enables great flexibility and decoupling of the systems.

https://github.com/juriansluiman/SlmQueue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!