Sunday, April 30, 2017

Using whenever gem with Rails

To list what crons are installed:
crontab -e

whenever gem is integrated with Capistrano.

gem 'whenever', require: false

wheneverize .

bundle exec wheneverize .

config/schedule.rb

Add:

every 1.day, at: '4:30 am' do
  rake 'clear_cache'
end

task clear_cache: :environment do
  Rails.cache.clear
end

bundle exec whenever

Backup prod db
Populate download geo co-ordinates once every day

When payment fails, send email using ActionMailer

For Capistrano integration, in config/deploy.rb:
require 'whenever/capistrano'