auto_cron

Powerful way to manage crontabs using capistrano.

Getting started

1) Add auto_cron to your Gemfile

2) In your capistrano deploy.rb file, add:

require “capistrano/auto_cron”

after “deploy:restart”, “auto_cron:publish”

3) If using ext/multistage: In deploy/production.rb, e.g. add:

set :auto_cron_templates, %w( publish production )

role :publish_crons, “cron-internal.example.com”

4) In config/auto_cron, add erb files corresponding to the files specified in step 3

e.g., config/auto_cron/publish.erb

# crons for production */5 * * * * cd /mnt/apps/mysite && bundle exec rake thinking_sphinx:index RAILS_ENV=<%= Rails.env %>

Advantages over other ruby cron managers

  • Uses crontab syntax, not a DSL that is going to get in your way

  • Uses ERB, everyone is familiar

  • Customize crons across environment

  • Crons are namespaced using application name specified in capistrano deploy file, so you can write crons for multiple apps to the same crontab without collision

Contributing to auto_cron

  • Contributions welcome, fork the project

Copyright © 2011 Alex Farrill. See LICENSE.txt for further details.