level_zebra
level_zebra

Reputation: 1533

Quartz.Net cron trigger to schedule a job every 45 minutes

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

I have tried to create this with a cron tigger using

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

however this is not working the way i want it to.

After looking at the quartz.net tutorials it is suggested to implement such a job would require using two triggers.

I am a little confused on how to implement this, can anyone advise on a solution

Upvotes: 6

Views: 6532

Answers (1)

yorah
yorah

Reputation: 2673

Quartz.Net Tutorials are mostly 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();

This will create a trigger, running every 45 minutes, between 8am and 11am.

Upvotes: 15

Related Questions