Laura Diane Hamilton

Technical Product Manager at Groupon


Using the whenever gem to manage scheduled jobs

Here is a brief tutorial explaining how to use the whenever gem to managed scheduled jobs in a rails app.

It was tested with whenever version 0.9.2 and rails version 4.0.4.

First, add the whenever gem to your Gemfile. gem 'whenever', :require => false

Next, from your application's root directory, run "wheneverize." cd /apps/myapp $ wheneverize . This will create a scheduler file, config/schedule.rb.

Next, configure your scheduler file to run your jobs according to the appropriate schedule.

require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
set :path, Rails.root
set :output, Rails.root.join('log', 'cron.log')

every do
  runner "Customer.email_happy_birthday"

The whenever gem converts your pretty defined-with-ruby jobs into crontab.

To check how config/schedule.rb converts ton cron syntax, run this command: whenever

Then finally, in order to update your crontab: whenever -i is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to