Schedule Quartz.NET trigger that executes once a w

2019-08-11 16:11发布

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条回答
贪生不怕死
2楼-- · 2019-08-11 16:38
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

查看更多
登录 后发表回答