Cronjobs
DSL to manage cronjobs in rails.
Why
I did this gem to:
- Enforce better practices removing unnecessary options.
- User plain old school cron syntax.
- Keep a close integration with rails.
Install
Put this line in your Gemfile:
gem 'cronjobs'
Then bundle:
$ bundle
Configuration
Generate the definitions file:
$ bundle exec rails g cronjobs:install
Set the global settings:
Cronjobs.define do
env 'PATH=$PATH:/usr/local/bin'
mailto 'test@mail.com'
output Rails.root.join('log/cronjobs.log')
end
Usage
Definitions
Add the jobs to the definitions file:
Cronjobs.define do
every '* 1 * * *' do
rake 'invoices:generate'
end
every '0 5 * * *' do
runner 'User.clear_guests'
end
end
Rake Task
In your deploy recipe use the rake task to update the cronjobs:
$ bundle exec rake cronjobs:update
Contributing
Any issue, pull request, comment of any kind is more than welcome!
I will mainly ensure compatibility to PostgreSQL, AWS, Redis, Elasticsearch, FreeBSD and Memcached.
Credits
This gem is maintained and funded by mmontossi.
License
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.