Simple scheduler that runs periodically.

Code is Really Simple.

scheduler = Rufus::Scheduler.start_new '20m' do
  puts "order ristretto"

The Usage is Really Simple In Rails Environment. I'll take the example of Rake task First. I will try to create a resque:work like task.

task :my_scheduler_work => :environment do
   scheduler = Rufus::Scheduler.start_new '20m' do

Doing This in an non rails Env.

For Ex: abcd.rake

require 'rake'
# require 'abcd' # File with all the classes and libs that are needed for rake task to run.

task :my_scheduler_work do

   scheduler = Rufus::Scheduler.start_new

   puts "scheduler is Running on PORT: #{$$}" '20m' do

Once you run the Rake Task U will see that, this will work endlessly.

  puts "scheduler is Running on PORT: #{$$}"

This will print the port number on which the scheduler is Running.

Finally run the rake task from the folder where u are developing the app.

   bundle exec rake my_scheduler_work

Thats It. I think, tats enough for basic understanding.

Click the following link for more details: [Rufus-Scheduler][1]