rufus-scheduler 3.2.1 released
I've just released rufus-scheduler 3.2.1.
Rufus-scheduler is a Ruby gem for scheduling pieces of code. You instantiate a scheduler and you tell it after how long you want a block of code to run or how often you want it to run.
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
scheduler.in '3h' do
# do something in 3 hours
end
scheduler.at '2030/12/12 23:30:00' do
# do something at a given point in time
end
scheduler.every '3h' do
# do something every 3 hours
end
scheduler.cron '5 0 * * *' do
# do something every day, five minutes after midnight
# (see "man 5 crontab" in your terminal)
end
scheduler.join
# let the current thread join the scheduler thread
This 3.2.1 release mostly brings negative weekdays to cron strings. It lets you write crons like:
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
scheduler.cron '5 0 * * 5L' do
# do something every last Friday of the month, at 00:05
end
scheduler.cron '5 0 * * 4#-2,4#-1' do
# do something every second to last and last Thursday of the month, at 00:05
end
#
# or
#
scheduler.cron '5 0 * * thu#-2,thu#-1' do
# do something every second to last and last Thursday of the month, at 00:05
end
scheduler.join
Many thanks to all the people that contributed to the development of rufus-scheduler.