I implement a schedule in MVC app to run job in every day midnight. This is the code.
IScheduler sched = container.Resolve<IScheduler>();
sched.JobFactory = new AutofacJobFactory(container);
sched.Start();
IJobDetail job = JobBuilder.Create<ProcessInvoiceJob>()
.WithIdentity("job1", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.WithCronSchedule("0 0 * * * ?")
.Build();
sched.ScheduleJob(job, trigger);
I read few articles and it contains cron expression for 12 midnight is "0 0 * * * ?"
Eg : http://blog.bobcravens.com/2009/10/an-event-based-cron-scheduled-job-in-c/
The issue is my schedule executes in every one hour... How to fix this?
You are telling it to execute on every hour, the correct CRON value for midnight only is 0 0 0 * * ?
Edit: The resource you used is from 2009 so I can see how this would be wrong, for reference the current CRON is "Seconds Minutes Hours Day-of-Month Month Day-of-Week Year (optional field)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With