Reputation: 2535
How can I express a schedule job that triggers every x min between 7:20AM-8:30PM Mon-Sun in Quartz.Net? I'm a bit confused and the testing would take time to confirm.
According to https://www.freeformatter.com/cron-expression-generator-quartz.html it would be "0 20-30 7-18 ? * MON,TUE,WED,THU,FRI,SAT,SUN *", but how can I express the 7:20-18:30?
Above expression generates next execution something like this, which is not what I expected.
Tue Sep 15 07:20:00 UTC 2020 Tue Sep 15 07:21:00 UTC 2020 Tue Sep 15 07:22:00 UTC 2020 Tue Sep 15 07:23:00 UTC 2020 Tue Sep 15 07:24:00 UTC 2020 Tue Sep 15 07:25:00 UTC 2020 Tue Sep 15 07:26:00 UTC 2020 Tue Sep 15 07:27:00 UTC 2020 Tue Sep 15 07:28:00 UTC 2020 Tue Sep 15 07:29:00 UTC 2020
And described as "At second :00, every minute between :20 and :30, every hour between 07am and 18pm, on every Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday, every month".
Upvotes: 0
Views: 397
Reputation: 413
If you're using quartz.net you might want to look at a different trigger type instead of a cron expression.
have a look at .WithDailyTimeIntervalSchedule
.WithDailyTimeIntervalSchedule(s=>
s.WithIntervalInMinutes(15)
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(7,20))
.EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(20,30))
Upvotes: 0
Reputation: 875
Based on the information, you will require essentially three cron expressions as you cannot specify exact time:
0 00-30/X 18-19 ? * *
0 20-59/X 07-08 ? * *
0 0/X 08-18 ? * *
I got rid of Monday-Sunday as it means every day. First one is to run between 6 pm & 6:30 pm. 2nd cron expression is run between 7:20am & before 8 am. Third one is run between 8am & 6pm.
/X is to run every X mins.
Upvotes: 0