Search code examples
ruby-on-railscronrufus-scheduler

Rufus Scheduler not running


I want to do something simple with the gem rufus-scheduler: https://github.com/jmettraux/rufus-scheduler

but, i can't get it to work.

I have a regular rails app. I created a .rb file:

# test_rufus_scheduler.rb
require 'rubygems'
require 'rufus/scheduler'

scheduler = Rufus::Scheduler.start_new

scheduler.in '1s' do
  puts "hello world"
end

Then, when I try ruby test_rufus_scheduler.rb, nothing happens. Am i doing it right? gem list shows rufus-scheduler.

Thanks.


Solution

  • If your script exits right away please try to add

    scheduler.join

    at the end. Please note that it's different when running the script stand alone and via rails. See the README for detailled information.