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" 

You can list installed cron jobs using crontab -l.


Cron jobs in Rails : Whenever gem or Scheduler in Heroku

To use autotriggered background processes in Ruby On Rails, we normally user gem like ‘Whenever‘. Its very easy to use.

Using single command like `whenever -i` will update your cron tab. To see your current Cron status you can simply use command like `whenever -l` or `crontab -l`.

Cron In Heroku

Continue reading