在Gearman中安排特定日期和时间的工作 [英] Schedule a job in Gearman for a specific date and time
问题描述
从我可以看到,Gearman不支持计划的作业或延迟的作业.我在想,也许计划的作业可以先在at
中排队,然后在at
时间段到期后添加到Gearman队列中.
From what I can see Gearman does not support scheduled jobs or delayed jobs. I was thinking that perhaps the scheduled job could be queued in at
first and then added to the Gearman queue after the at
time period has expired.
at
任务是持久性的,因为它们被作为文件写入服务器的假脱机目录中的目录中.因此,唯一的瓶颈可能是将任务添加到Gearman队列的简单脚本,因为at
不能在服务器之间分布.将其传递给Gearman来处理实际的工作意味着我可以进行适当的工作记录等.
at
tasks are persistent as they are written as files to a directory in the spool directory of the server. So the only bottle neck would potentially be a simple script to add the task to the Gearman queue because at
can't be distributed across servers. Passing it to Gearman to process the actual job means I can get proper job logging etc.
这是解决此问题的最佳方法,您还有其他选择吗?
Is this the best way to approach this and do you have any alternative ideas?
我之所以选择Gearman而不是其他队列解决方案,是因为它具有PHP扩展名.
The reason I have opted for Gearman over other queue solutions is that it has a PHP extension.
我正在编写的代码用于维护需要发送的电子邮件队列.因此,我可以指定例如要在星期五的9.50发送电子邮件到example@example.org.
The code I am writing is used to maintain a queue of emails that need to be sent out. So I may specify that I want to send an email to example@example.org at 9.50 on Friday for example.
推荐答案
我决定按照我在问题中最初提出的方法使用at
路线.为此,我为at
二进制文件编写了一个PHP包装程序,并在Ubuntu上对其进行了测试.如果您有兴趣,可以在github上找到它: http://github.com /treffynnon/PHP-at-Job-Queue-Wrapper
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
这篇关于在Gearman中安排特定日期和时间的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!