Whenever: Cron jobs by Ruby DSL


In this article, I would like to share whenever which provides a clear syntax for writing and deploying cron jobs.

🏀 Set PATH for cron job

If you want to add PATH for cron job, please write as follows:

require './config/environment.rb'

set :environment_variable, 'RAILS_ENV'
set :environment, Rails.env

# Set Path
set :path, Rails.root.to_s

# Set log file path
set :output, 'log/crontab.log'

# Set PATH for cron job and MAIL_TO
set :env, { 'PATH' => '/xxx/bin:$PATH', 'MAILTO' => '[email protected]' }

every 1.hours do
# do_something
end

😎 Special Thanks

🖥 Recommended VPS Service

VULTR provides high performance cloud compute environment for you. Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour). In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!