Hello,
---8<---
require 'chronic'
scheduler = Rufus::Scheduler.start_new
if Rails.env == 'development'
opts = {}
first_at = Chronic.parse('February 7 2011 at 5pm')
opts[:first_at] = first_at if first_at < Time.now
scheduler.every '20m', opts do
User.send_emails
end
end
--->8---
Best regards,
--
John Mettraux - http://jmettraux.wordpress.com
Hello,
sorry for my terse response, I thought the code said it all.
I simply don't pass the :first_at if it points to the past.
Usually people will use first_at with some relative value
scheduler.every '2d', :first_at => Time.now + 3600 do
# ...
end
Your first_at is "hardcoded", simply put it away.
Hello again,
why are you wasting your time with an "every" ?
---8<---
scheduler.cron '0 6 * * mon' do
# do it...
end
--->8---
will run every monday at 6am.
Hello,
why not something like
---8<---
alternate = true
scheduler.cron '0 6 * * mon' do
if alternate
# do it
end
alternate = ! alternate
end
--->8---
?
https://github.com/mojombo/chronic
---8<---
schedule.every '2w', :first_at => Chronic.parse('next tuesday') do
# just do it ...
end if Rails.env == 'development'
--->8---