使延迟的作业在特定日期时间运行

编程入门 行业动态 更新时间:2024-10-22 11:30:11
本文介绍了使延迟的作业在特定日期时间运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想通过 delayed_job

发送一些电子邮件,但是我想在事件。

However, I want to send them before and after an event.

我担心的是这是否真的有效:

My concern is if this will actually work:

def one_week_before_run AtendeeMailer.delay(run_at: '8th October 2016'.to_datetime).mudrun_about_to_start(self) end def thank_you_note AtendeeMailer.delay(run_at: '18th October 2016'.to_datetime.end_of_day).thank_you(self) end

或我应该选择另一种方法吗?

or should I choose another approach?

推荐答案

仅当run_at< =当前时间时,延迟的作业才会选择要执行的作业。引用DJ的查询来选择工作

Delayed job picks a job to execute only if the run_at <= current time. Refer DJ's query to pick job

SELECT `delayed_jobs`.* FROM `delayed_jobs` WHERE ((run_at <= '2016-09-27 00:49:59' AND (locked_at IS NULL OR locked_at < '2016-09-27 00:24:59') OR locked_by = 'host:Madhubalans-Air pid:74314') AND failed_at IS NULL) ORDER BY priority ASC, run_at ASC LIMIT 1

您的代码将run_at设置为2016-10-18 00 :00:00和2016-10-18 23:59:59。 因此,您的代码将按您的期望运行:)

Your code is setting run_at to 2016-10-18 00:00:00 and 2016-10-18 23:59:59. So your code will work as per your expectation :)

更多推荐

使延迟的作业在特定日期时间运行

本文发布于:2023-11-27 09:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637490.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   日期   时间   在特定

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!