2

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);
Jack
  • 1
  • 21
  • 118
  • 236
  • One thing I would do is be sure that using Quartz.net is worth it. Have a look at this question. Theanswer is quite helpful http://stackoverflow.com/questions/5115105/quartz-net-vs-windows-scheduled-tasks-how-different-are-they – Dan Dec 01 '15 at 17:31
  • Thanks, but I did not see an answer that is useful for my question :( – Jack Dec 02 '15 at 08:59
  • What feature of Quartz.net do you need? Why are you using it instead of using a simple console application which is started by Windows Task Scheduler? – Dan Dec 03 '15 at 12:32
  • 2
    I just want to create a weekly schedule using Quartz.net. Why I am using it instead of using a simple console application which is started by Windows Task Scheduler is a long story. – Jack Dec 07 '15 at 08:44
  • Did you ever find the solution to this issue? It would be great if you could post your answer. – SM3RKY Mar 01 '16 at 02:43
  • 1
    @SM3RKY Sorry for late answer. I solved the problem by applying the sample mentioned on [this](http://stackoverflow.com/a/35071844/1604048) page. Let me know if it solves your problem as well. Regards... – Jack Mar 20 '16 at 12:43

1 Answers1

3
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

Pradeep
  • 9,667
  • 13
  • 27
  • 34
Imran Ali
  • 31
  • 4