-
-
Save richcorbs/5220305 to your computer and use it in GitHub Desktop.
Rufus scheduler single cron, multiple "tasks", with and without mutex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rufus-scheduler' | |
scheduler = Rufus::Scheduler.start_new | |
# without mutex | |
scheduler.cron '*/1 * * * *' do | |
puts '1' | |
sleep 10 | |
puts '2' | |
sleep 5 | |
puts '3' | |
end | |
# with mutex | |
# scheduler.cron '*/1 * * * *', :mutex => 'my_mutex' do | |
# puts '1' | |
# sleep 10 | |
# puts '2' | |
# sleep 5 | |
# puts '3' | |
# end | |
scheduler.join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OUTPUT FOR BOTH | |
1 | |
# 10 second pause | |
2 | |
# 5 second pause | |
3 | |
# 45 second pause | |
1 | |
# 10 second pause | |
2 | |
# 5 second pause | |
3 | |
# 45 second pause | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment