Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 352
level_zebra Avatar asked Jul 04 '12 14:07

level_zebra


1 Answers

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.

like image 109
yorah Avatar answered Sep 28 '22 19:09

yorah