延迟作业与 cron
我有一个系统,用户进来完成一个包含多个部分的申请流程 - 有时用户会保存他们的进度并稍后再回来。
如果用户在 48 小时内没有回来,我想向他们发送一封电子邮件 - 最好使用 cron
、delayed_job
或 来执行此操作每当
?
我注意到,每当我在控制台中运行操作(例如 bundle install
或 rake db:migrate
)时,它也会运行 cron,这让我怀疑我们可能存在用户在同一天收到多个提醒的情况。
您对此有何建议?
I have a system where users come in to go through an application process that has multiple parts - sometimes users will save their progress and come back later.
I want to send users an e-mail if they haven't come back in 48 hours - would it be best to do this using cron
, delayed_job
, or whenever
?
I've noticed that whenever I run operations in the console (such as bundle install
or rake db:migrate
) it runs cron as well, which makes me suspicious that we may have instances where users get multiple reminders in the same day.
What are your recommendations for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,Whenever 和 Cron 是同义词。 Whenever 所做的一切就是为您提供一种使用 Ruby 编写 cronjobs 的方法(这太棒了,我喜欢 Everever)。
Delayed_job 不是这里的答案。你肯定想使用 cronjobs。在您的应用程序模型上创建一个方法,该方法将获取
updated_at
值为的应用程序。 2.days.ago
并向申请人发送电子邮件。还有你的 UserMailer:
使用每当创建这个 cron:
First of all, Whenever and Cron are synonymous. All Whenever does is provide a way for you to write cronjobs using Ruby (which is awesome, I love Whenever).
Delayed_job is not the answer here. You definitely want to use cronjobs. Create a method on your Application model that will get applications which have an
updated_at
value of< 2.days.ago
and e-mail its applicant.And your UserMailer:
Using whenever to create this cron: