sidekiq-scheduler icon indicating copy to clipboard operation
sidekiq-scheduler copied to clipboard

Documentation shows six * and it should be five

Open zayter opened this issue 2 years ago • 3 comments

image

right now it follows this way https://crontab.guru/ but documentation is different

Tested on Rails 6+

zayter avatar Dec 07 '22 16:12 zayter

I guess it should be 6 *:

  1. seconds
  2. minutes
  3. hours
  4. day
  5. month
  6. day week

regular crontab (5 *) + 1 * for seconds

palexvs avatar Dec 13 '22 08:12 palexvs

You can use fugit gem to test the notations, it's used behind the scenes by rufus

[1] pry(main)> Fugit.parse('0 * * * * *')
=> #<Fugit::Cron:0x0000000139d6de38 @cron_s=nil, @hours=nil, @minutes=nil, @monthdays=nil, @months=nil, @original="0 * * * * *", @seconds=[0], @timezone=nil, @weekdays=nil, @zone=nil>

jonatasrancan avatar Sep 01 '23 14:09 jonatasrancan

For my case it was confirmed, that 5 symbols should be used for cron expressions in sidekiq.yml. We needed to perform job every Monday at 12:00

  1. According to documentation (6 symbols):
Fugit.parse('0 12 * * 1 *')
=> #<Fugit::Cron:0x00000001100139c8
 @cron_s=nil,
 @day_and=nil,
 @hours=nil, # wrong
 @minutes=[12],
 @monthdays=nil,
 @months=[1],
 @original="0 12 * * 1 *",
 @seconds=[0],
 @timezone=nil,
 @weekdays=nil,
 @zone=nil>
  1. Pattern with 5 symbols (correct):
Fugit.parse('0 12 * * 1')
=> #<Fugit::Cron:0x0000000115e9f780
 @cron_s=nil,
 @day_and=nil,
 @hours=[12],
 @minutes=[0],
 @monthdays=nil,
 @months=nil,
 @original="0 12 * * 1",
 @seconds=[0],
 @timezone=nil,
 @weekdays=[[1]],
 @zone=nil>

unavailabl3 avatar Dec 13 '23 08:12 unavailabl3

@unavailabl3 in practice both work but each behaves in a different way, as @palexvs said, if you provide six arguments, this is what it will expect

  1. seconds
  2. minutes
  3. hours
  4. day
  5. month
  6. day week

if you provide five, then this is what it will expect

  1. minute
  2. hours
  3. day
  4. monh
  5. day week

see documentation of fugit, please https://github.com/floraison/fugit?tab=readme-ov-file#the-second-extension

in your example, with 6 symbols @unavailabl3 , it should be

Fugit.parse('0 0 12 * * 1')

or 👇 if seconds don't matter

Fugit.parse('* 0 12 * * 1')

~~Some examples in the readme are wrong, though (i.e. saying "runs once per minute" where the example will run it once per second), so I am fixing that!~~ Well maybe not, maybe I am just dumb 🤦

marcelolx avatar May 16 '24 12:05 marcelolx

Mention about the support of 6 arguments added to the readme https://github.com/sidekiq-scheduler/sidekiq-scheduler/commit/58e18351054fc3c264b2b5a684173316f674c386

marcelolx avatar May 16 '24 12:05 marcelolx