Whenever : Cron tab : Environment selection

For whenever gem Default Rails environment is production. However, you sometime would like to set environment manually for testing purposes.

If you try

$ whenever -h
Usage: whenever [options]
 -s, --set [variables] Example: --set 'environment=staging&path=/my/sweet/path'

if you need to set environment to development then try this

$ whenever --update-crontab --set 'environment=development'

 

# In schedule.rb
# run this task only on servers with the :app role in Capistrano
# see Capistrano roles section below

# variable `environment` is accessible here; you set from CLI
set :whenever_environment, environment || 'production'

every :day, :at => '12:20am', :roles => [:app] do 
  rake "app_server:task" 
end

You can list installed cron jobs using crontab -l.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s