Add this line to your application's Gemfile:
gem 'cronie', git: 'https://github.com/labocho/cronie.git'
And then execute:
$ bundle
Create Croniefile
.
# Optional time zone setting
set_utc_offset "+09:00"
# Define task
task "Daily task at 00:30", "0 30 * * *" do
do_monthly_task
end
# Omit title
task "0 * * * *" do
do_hourly_task
end
# Omit schedule (run every minute)
task do
do_hourly_task
end
In your application.
require "cronie"
Cronie.load("./Croniefile")
Cronie.run(Time.now)
In your application.
require "resque/active_job"
Cronie.load("./Croniefile")
Register job via Ruby.
Cronie.perform_later(Time.now.to_i)
If you use resque, you can add job via redis-cli.
$ redis-cli sadd resque:queues cronie
$ redis-cli rpush resque:queue:cronie '{"class":"Cronie","args":'`date +%s`'}'
Run worker that processes cronie
queue.
$ rake resque:work QUEUE=cronie
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request