README.md in rufus-scheduler-3.2.0 vs README.md in rufus-scheduler-3.2.1

- old
+ new

@@ -1,17 +1,19 @@ # rufus-scheduler -[![Build Status](https://secure.travis-ci.org/jmettraux/rufus-scheduler.png)](http://travis-ci.org/jmettraux/rufus-scheduler) -[![Gem Version](https://badge.fury.io/rb/rufus-scheduler.png)](http://badge.fury.io/rb/rufus-scheduler) +[![Build Status](https://secure.travis-ci.org/jmettraux/rufus-scheduler.svg)](http://travis-ci.org/jmettraux/rufus-scheduler) +[![Gem Version](https://badge.fury.io/rb/rufus-scheduler.svg)](http://badge.fury.io/rb/rufus-scheduler) Job scheduler for Ruby (at, cron, in and every jobs). **Note**: maybe are you looking for the [README of rufus-scheduler 2.x](https://github.com/jmettraux/rufus-scheduler/blob/two/README.rdoc)? Quickstart: ```ruby +# quickstart.rb + require 'rufus-scheduler' scheduler = Rufus::Scheduler.new scheduler.in '3s' do @@ -19,10 +21,11 @@ end scheduler.join # let the current thread join the scheduler thread ``` +(run with `ruby quickstart.rb`) Various forms of scheduling are supported: ```ruby require 'rufus-scheduler' @@ -57,13 +60,14 @@ It does not persist your schedules. When the process is gone and the scheduler instance with it, the schedules are gone. ## related and similar gems -* [whenever](https://github.com/javan/whenever) - let cron call back your Ruby code, trusted and reliable cron drives your schedule -* [clockwork](https://github.com/tomykaira/clockwork) - rufus-scheduler inspired gem -* [crono](https://github.com/plashchynski/crono) - an in-Rails cron scheduler +* [Whenever](https://github.com/javan/whenever) - let cron call back your Ruby code, trusted and reliable cron drives your schedule +* [Clockwork](https://github.com/tomykaira/clockwork) - rufus-scheduler inspired gem +* [Crono](https://github.com/plashchynski/crono) - an in-Rails cron scheduler +* [PerfectSched](https://github.com/treasure-data/perfectsched) - highly available distributed cron built on [Sequel](http://sequel.jeremyevans.net) and more (please note: rufus-scheduler is not a cron replacement) ## note about the 3.0 line @@ -99,16 +103,10 @@ Go read [how to report bugs effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html), twice. Update: [help_help.md](https://gist.github.com/jmettraux/310fed75f568fd731814) might help help you. -### on StackOverflow - -Use this [form](http://stackoverflow.com/questions/ask?tags=rufus-scheduler+ruby). It'll create a question flagged "rufus-scheduler" and "ruby". - -Here are the [questions tagged rufus-scheduler](http://stackoverflow.com/questions/tagged/rufus-scheduler). - ### on IRC I sometimes haunt #ruote on freenode.net. The channel is not dedicated to rufus-scheduler, so if you ask a question, first mention it's about rufus-scheduler. Please note that I prefer helping over Stack Overflow because it's more searchable than the ruote IRC archive. @@ -121,10 +119,12 @@ * [It doesn't work...](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) * [I want a refund](http://blog.nodejitsu.com/getting-refunds-on-open-source-projects) * [Passenger and rufus-scheduler](http://stackoverflow.com/questions/18108719/debugging-rufus-scheduler/18156180#18156180) * [Passenger and rufus-scheduler (2)](http://stackoverflow.com/questions/21861387/rufus-cron-job-not-working-in-apache-passenger#answer-21868555) +* [Passenger in-depth spawn methods](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/) +* [Passenger in-depth spawn methods (smart spawning)](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#smart-spawning-hooks) * [The scheduler comes up when running the Rails console](https://github.com/jmettraux/rufus-scheduler#avoid-scheduling-when-running-the-ruby-on-rails-console) * [I don't get any of this, I just want it to work in my Rails application](#so-rails) ## scheduling @@ -179,10 +179,12 @@ Interval jobs, trigger, execute and then trigger again after the interval elapsed. (every jobs time between trigger times, interval jobs time between trigger termination and the next trigger start). Cron jobs are based on the venerable cron utility (```man 5 crontab```). They trigger following a pattern given in (almost) the same language cron uses. +#### + ### #schedule_x vs #x schedule_in, schedule_at, schedule_cron, etc will return the new Job instance. in, at, cron will return the new Job instance's id (a String). @@ -1346,20 +1348,34 @@ #### L (last day of month) L can be used in the "day" slot: In this example, the cronline is supposed to trigger every last day of the month at noon: - ```ruby require 'rufus-scheduler' Time.now # => 2013-10-26 07:22:09 +0900 Rufus::Scheduler.parse('00 12 L * *').next_time # => 2013-10-31 12:00:00 +0900 ``` +#### negative day (x days before the end of the month) +It's OK to pass negative values in the "day" slot: +```ruby +scheduler.cron '0 0 -5 * *' do + # do it at 00h00 5 days before the end of the month... +end +``` + +Negative ranges (`-10--5-`: 10 days before the end of the month to 5 days before the end of the month) are OK, but mixed positive / negative ranges will raise an `ArgumentError`. + +Negative ranges with increments (`-10---2/2`) are accepted as well. + +Descending day ranges are not accepted (`10-8` or `-8--10` for example). + + ## a note about timezones Cron schedules and at schedules support the specification of a timezone. ```ruby @@ -1443,10 +1459,10 @@ s = Rufus::Scheduler.singleton unless defined?(Rails::Console) - # only schedule when not running from the Rails on Rails console + # only schedule when not running from the Ruby on Rails console s.every '1m' do Rails.logger.info "hello, it's #{Time.now}" Rails.logger.flush