如何使用 rufus-scheduler 从特定日期开始每两周运行一次任务
我试图从今天开始每两周运行一次任务,但在我的测试中,当 rufus 调度程序启动时,它会尝试运行该任务,无论它“错过”多少次,直到它赶上。
例如,如果我
require 'chronic'
scheduler = Rufus::Scheduler.start_new
scheduler.every '20m', :first_at => Chronic.parse('February 7 2011 at 5pm') do
User.send_emails if Rails.env.eql?('development')
end
在时间为 5:57 时尝试类似的操作...调度程序将尝试发送电子邮件两次,以弥补在 5:20 和 5:40 处“错过”的时间...感觉? 有没有办法让它正常发送而不试图“赶上”?
I'm trying to run a task every two weeks starting today, but in my tests, its seems that when rufus scheduler starts up, it tries to run the task however many times it has 'missed' until it catches up.
So for example, if I try something like this
require 'chronic'
scheduler = Rufus::Scheduler.start_new
scheduler.every '20m', :first_at => Chronic.parse('February 7 2011 at 5pm') do
User.send_emails if Rails.env.eql?('development')
end
if the time is 5:57 ... scheduler will try to send the emails twice to make up for the times it 'missed' at 5:20 and 5:40 ... make sense?
Is there a way to get it to send as normal without trying to 'catch up'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答于 http://groups.google.com/group/rufus-ruby /browse_thread/thread/e0aa06d29ae4ef69
Answered at http://groups.google.com/group/rufus-ruby/browse_thread/thread/e0aa06d29ae4ef69