Search code examples
c#.netschedulerquartz

Run Quartz job at specified time


I have a job in Quartz Scheduler which deletes rows from database and I want it to run everyday at 00:00. Currently it has intervalInMinutes set to 1440 (24hrs) but it's wrong. How to set this to run everyday at 00:00?

Code snippet:

x.AddTrigger(x => x,
.ForJob(delete)
.StartNow()
.WithSimpleSchedule(s => s
    .WithIntervalInMinutes(1440)
    .RepeatForever()
);

Solution

  • There is a simple configuration for a specific recurring job trigger which is like below :

    ITrigger t = TriggerBuilder.Create()
            .WithIdentity("myTrigger")
            .ForJob("myJob")
            .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0,0)) // execute job daily at 00:00
            .Build();