Christian Benseler
Christian Benseler

Reputation: 8065

Rails + Whenever: run tasks with same schedule in different days

I'm using whenever gem to run schedule jobs. My schedule.rb has something like this:

every 3.days, :at => '2:10 pm' do
   runner "Something.task()"
end

every 3.days, :at => '1:10 pm' do
   runner "Something.othertask()"
end

The thing is, is it possible to define that the first job starts to run today and other, only tomorrow? So they will never run at the same day.

Upvotes: 0

Views: 817

Answers (1)

user4384619
user4384619

Reputation:

You can use raw cron syntax as well if you cant figure out how to use with ruby syntax.

What you want will look like:

every '0 2 20 * *' do
  command "echo 'you can use raw cron sytax too'"
end

Here is a quick cheatseet for how to use cron syntax

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

from: http://adminschoice.com/crontab-quick-reference

Upvotes: 2

Related Questions