-2

I have this very simple code to run rufus/scheduler:

require 'rufus/scheduler'
require 'rubygems'

scheduler = Rufus::Scheduler.new

scheduler.every '1s' do 
puts "Hello world"

end
scheduler.join

This doesn't seem to work and I get no result.

Rohan Dalvi
  • 1,215
  • 1
  • 16
  • 38
  • How do you run it? ruby or irb? what version of ruby? No output at all? Your code works for me, although @hwatkins code is better. – jmettraux Nov 25 '13 at 04:20

1 Answers1

1

You are including the wrong gem, try this:

require 'rubygems'
require 'rufus-scheduler'

scheduler = Rufus::Scheduler.new

scheduler.every '1s' do 
puts "Hello world"

end
scheduler.join
hwatkins
  • 1,416
  • 8
  • 11
  • `require 'rufus-scheduler'` doesn't work for me, `rufus/scheduler` worked fine. Let's say i am running scheduler.every '5m' what happens if my code doesn't complete execution in that time? Does a new instance of execution abort my current process and starts over again? – Rohan Dalvi Nov 25 '13 at 14:14
  • Try doing 'gem install rufus-scheduler' first. Make sure 'rubygems' is required first. It looks like there is no check to see if code is still running from a previous invocation, so you would have to synchronize that outside of rufus. – hwatkins Nov 25 '13 at 18:35