Showing posts with label scheduler. Show all posts
Showing posts with label scheduler. Show all posts

Tuesday, May 11, 2010

Rufus scheduler sample

After creating ruby script, Im using rufus scheduler. I found this simple snippet and so far its helpful. The file filerun.rb is executing every 20 seconds.

Installation

sudo gem install rufus-scheduler
Sample usage:
require 'filetorun'
require 'rufus/scheduler'

class Scheduler
 def start
   scheduler = Rufus::Scheduler.start_new
   scheduler.every '20s', :blocking =>; true do
      puts "running test"
     `ruby filetorun.rb`
   end
   scheduler.join
 end
end

Scheduler.new.start