public
Description: Provides clean ruby syntax for defining messy cron jobs and running them Whenever.
Home | Edit | New

Setting variables on the fly

If you wish to override variables in your schedule.rb file at runtime you can do so using the --set option. This is especially useful for changing your environment when deploying to a staging server or something similar.

Example:

whenever --set environment=staging

You can set more than one variable by forming a query string. Make sure to use quotes.

whenever --set 'environment=staging&cron_log=/my/other/log.txt'

So you can define different tasks per environment:

case @environment
when 'production'
  every 1.day, :at => "#{Time.parse('12:00 A').getlocal.strftime("%H:%M")}" do
    runner "Company.send_later(:create_daily_stories!)"
  end 
when 'staging'
  every 15.minutes do
    command "thinking_sphinx_searchd  reindex"
  end
end

Last edited by guillermo, Wed Nov 04 07:10:17 -0800 2009
Home | Edit | New
Versions: