Web Development

The whenever is a gem that allows you to write cron jobs easily.

every 2.hours do
  command "mysqldump db > db.sql"
every :day, :at => '12:20am' do
  command "mysqldump db > db.sql"

whenever: command not found

A whenever: command not found error is shown whenever the whenever gem is not installed or cannot be seen

$ whenever
whenever: command not found
$ gem list | grep whenever

The thing since we almost always use bundler, you should use the bundle exec command:

$ bundle show whenever

So running whenever commands would be:

$ bundle exec whenever
0 0,12 * * * /bin/bash -l -c 'mysqldump -u username -p password database_name | bzip2 -c > backup_$(date +\%Y-\%m-\%d-\%H.\%M.\%S).sql.bz2'

Write crontab

$ bundle exec whenever -w
[write] crontab file written