since-when is a way to manage repeated cron-like jobs in ruby. Rather than trying to recreate or replace proven scheduling tools, it works with them.
Add this line to your application's Gemfile:
gem 'since-when', github: 'modcloth-labs/since-when'
then execute:
$ bundle
SinceWhen::MissedRunner.new('/path/to/metafile').run(:day) do |time|
# run your job with each yielded time
end
-
since-when will use the metafile to track when your job ran last, and calculate the in-between times it should have run since the last run.
-
If your job completes successfuly, since-when will update the metafile based on the last successful run time.
-
If your job raise an exception, since-when will handle it by only updating the metafile to the last successful runtime (or not at all if all job executions failed).
- 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