问题
I need to schedule Quartz.NET trigger so that it fires on every Monday at 09.00. So, I tried to use some features as below but I think it does not true as the parameters are not logical (It worked for daily scheduling, but after change to this it does not). So, could you please give an example that executes job weekly?
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithInterval(1, IntervalUnit.Week)
.OnDaysOfTheWeek(DayOfWeek.Monday)
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(9, 0))
)
.Build();
scheduler.ScheduleJob(job, trigger);
回答1:
ITrigger trigger= TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.WithSchedule(CronScheduleBuilder.CronSchedule("0 0 9 ? * MON")).Build();
scheduler.ScheduleJob(job, trigger);
Please try the above code. Here, I am passing a parameter "0 0 9 ? * MON" by which the trigger will be fired Monday at 09.00.
For reference click here http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html
来源:https://stackoverflow.com/questions/34026183/schedule-quartz-net-trigger-that-executes-once-a-week