Reputation: 9416
public static ITrigger FireEveryDayAtMidnight()
{
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger3", "group1")
.WithCronSchedule("0 02 01 * * ?")
.ForJob("myJob", "group1")
.Build();
return trigger;
}
I have a problem thoroughly understanding Cron Trigger Expressions. I intend to schedule the above trigger to fire every day at 2 minutes past midnight. I just want to hear from people much more experienced with cron expressions if my expression above "0 02 01 * * ?", will indeed run as intended i.e run fire every day at 2 minutes past midnight
Upvotes: 2
Views: 468
Reputation: 5872
The cron in your trigger will execute at 02:00 on the 1st of every month.
If you wish to execute it at 00:02 every day using the 7 field Quartz contrab format, use:
0 2 0 * * * * ?
Here's a quick summary of how crons are formed, snipped from the Cron How To on Ubuntu's site:
Each of the sections is separated by a space, with the final section having one or more spaces in it. No spaces are allowed within Sections 1-7, only between them. Sections 1-7 are used to indicate when and how often you want the task to be executed. This is how a cron job is laid out:
second (0-59), minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday), year (empty, 1970-2099) command.
Upvotes: 2