Quartz.Net cron runs a schedule every 45 minutes

I am trying to create a job with quartz.net that will start every 45 minutes between the start time and the end time.

I tried to create this using cron tigger using

cronExpression = "0 0/45 8-5 * *?";

however, this does not work the way I want.

After viewing the quartz.net tutorials, it is proposed to implement a task that will require the use of two triggers.

I'm a little confused about how to implement this, can anyone advise a solution?

+5
source share
1 answer

Quartz.Net tutorials are mainly based on Quartz.Net v1.

If you are using v2 +, you can use the following trigger definition:

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger1", "group1")
    .WithDailyTimeIntervalSchedule(
        x => x.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(8, 0))
                 .EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(11, 0))
                 .WithIntervalInMinutes(45))
    .Build();

, 45 , 8:00 11:00.

+14

All Articles