0

I am using the Quartz Scheduling and I've tried to create a trigger that starts every day at 9 AM until 5 PM, every 25 minutes. It should like that: 9:00, 9:25, 9:50, 10:15, 10:40, 11:05, etc

The final quarts expression looks like that: 0 0/25 9-17 * * ? *

But the execution looks like that: 9:00, 9:25, 9:50, 10:00, 10:25, 10:50, 11:00, etc

There is any way to reach this schedule: 9:00, 9:25, 9:50, 10:15, 10:40, 11:05, etc or I should change quartz?

Thank you!

Ovidiu Rudi
  • 191
  • 1
  • 15

1 Answers1

0

Actually this question is similar to Cron expression to be executed every 45 minutes SO question.

Cron expression will not allow you to do that as it defines the exact date and times, when a trigger must be fired. And setup like your actually means "fire every 25 minutes, starting at minute 0 of every hour".

You can achive what you want by using SimpleTrigger with .WithIntervalInMinutes(25) configuration.

SimpleTrigger should meet your scheduling needs if you need to have a job execute exactly once at a specific moment in time, or at a specific moment in time followed by repeats at a specific interval.

P.S. Your cron expression will work for 20 minutes (0 0/20 9-17 * * ? *), as 60 is a multiple of 20. Just in case changing interval is not critical to you)

P.S.2 To be honest you can use Cron expressions if setup few trigger for different intervals, but that is useless. Anyway look onto this SO answer

Community
  • 1
  • 1
Set
  • 47,577
  • 22
  • 132
  • 150