Hello people,
I am using Rufus scheduler to send emails every day at 4am. To do this I
am using:
scheduler = Rufus::Scheduler.start_new
scheduler.every ‘1d’, :first_at => ‘2010/04/1 04:30’ do
#do something
end
There is a better way to write this schedule ?
By the way, I placed this code at config/environments/production.rb, but
don’t seems to me that is the correct place. Is this the best way to go
?
Hm…seems like a better aproach…
How about this schedule to run every day…is it correct? Looks like
strange for me have to define the “:first_at” param…
Anderson L. wrote:
Hello people,
I am using Rufus scheduler to send emails every day at 4am. To do this I
am using:
scheduler = Rufus::Scheduler.start_new
scheduler.every ‘1d’, :first_at => ‘2010/04/1 04:30’ do
#do something
end
There is a better way to write this schedule ?
By the way, I placed this code at config/environments/production.rb, but
don’t seems to me that is the correct place. Is this the best way to go
?
I created a file called config/initializers/task_scheduler.rb which
looks like this:
scheduler = Rufus::Scheduler::PlainScheduler.start_new
scheduler.every “7m” do
sweep_for_reports
#puts “#{Time.now.to_s(:db)} – Swept for reports.”
end
scheduler.cron ‘22 1 * * *’ do
gather_event_data
puts “#{Time.now.to_s(:db)} – Gathered data.”
end
An easier way to write your schedule, probably, is to use cron-style.
4AM every day would be like this (this, mind you, is a matter of
preference!):
scheduler.cron ‘0 4 * * *’ do
send_emails :to => these_guys :about => that
end