0

i have a cron expression- 0 0 12 */2 * ?

If start date is monday and time is 11:40 am, the next trigger date i'm expecting is monday 12:00, followed by wednesday, friday,etc.

But when i give this expression, the first trigger is set to tuesday 12:00, followed by thursday, saturday,etc i verified this on http://cronmaker.com Why does this behavior occur for monday? If the start date is set to any other day it seems to behave the way its supposed to. So if it was set on Tuesday 11:50 am , the first trigger is on tuesday 12:00.

Please help me understand. Is it a bug or expected behavior? Is there a work around to make it trigger on monday?

Thanks

sharat
  • 160
  • 3
  • 10

2 Answers2

0

Your cron schedule doesn't care about the day of the week. It is running simply on every uneven day of the month. This is the expected behaviour.

If you need it to run on Mondays, you should use something like 0 0 12 ? * MON,WED,FRI

0

First of all you expression only uses ? for the day of the week, so effectively you are not controlling that part.

Second the / character in a Cron expression indicates an increment. And when used next to a *, the star just means the lower bound for that value, 1 for the day of the month.

So indeed you are asking for a fire at noon every uneven day of the month. And the start time of the trigger will only constrain the first instance to be the next uneven day of the month.

You cannot express what you seem to desire with a cron trigger - that is a schedule which is based off the start time of the trigger. You should use s SimpleTrigger for this

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43