Question

Well. I'm trying to write simple scheduler in ruby, just simple script which once started will every for ex. minute do something I want.

I've been using already rufus-scheduler with Ruby On Rails, but this time I don't really need all framework, because it will be just simple script.

So, I've wrote something like this:

require 'rubygems'; require 'rufus/scheduler'

scheduler = Rufus::Scheduler.start_new

scheduler.every '5s' do
    puts "Helo"
end

and when I'm starting it (I'm using Win Vista) it does actually nothing.

D:\>ruby scheduler.rb

D:\>

I've checked this out in irb, and.. it works.

irb(main):002:0> require 'rubygems'; require 'rufus/scheduler'
=> true
irb(main):003:0> scheduler = Rufus::Scheduler.start_new
=> #<Rufus::Scheduler::PlainScheduler: [...]
irb(main):004:0> scheduler.every '5s' do
irb(main):005:1* puts "Hello"
irb(main):006:1> end
=> #<Rufus::Scheduler::EveryJob:0x2e6fcb0 @scheduler=#<Ruf [...]
irb(main):007:0> Hello
Hello
Hello

Can someone help me with this? Thanks in advance.

Was it helpful?

Solution

Finally, I figured out how to solve this problem. Simply put

scheduler.join

at the end of script.

Here is a thread about similar problem :) https://groups.google.com/forum/?fromgroups#!topic/rufus-ruby/37DLuN2W_0w

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top