Sunday, January 30, 2011

New in Quartz.Net 2.0–The Calendar Interval Trigger

NOTE: I'm now blogging at and not updating this blog anymore. For information on the latest version of Quartz.Net, visit me there.

This is the first post of what will become a series of posts highlighting the new features that will be available in Quartz.Net 2.0.
To kick off the series, we will take a look at the CalendarIntervalTrigger. This trigger is used to fire jobs based on a recurring calendar time interval. The following time intervals are available:
This trigger has a RepeatInterval property, which can be used to indicate that the trigger should fire every N intervals. For example, if you set the RepeatIntervalUnit to Week and the RepeatInterval to 2, your trigger will fire every two weeks.
Here is what the source code documentation says about this trigger:
A concrete ITrigger that is used to fire a IJobDetail based upon repeating calendar time intervals.
The trigger will fire every N (see RepeatInterval) units of calendar time (see RepeatIntervalUnit) as specified in the trigger's definition.  This trigger can achieve schedules that are not possible with ISimpleTrigger (e.g because months are not a fixed number of seconds) or ICronTrigger (e.g. because "every 5 months" is not an even divisor of 12).
If you use an interval unit of IntervalUnit.Month then care should be taken when setting the startTime value that is on a day near the end of the month.  For example, if you choose a start time that occurs on January 31st, and have a trigger with unit IntervalUnit.Month and interval 1, then the next fire time will be February 28th, and the next time after that will be March 28th - and essentially each subsequent firing will occur on the 28th of the month, even if a 31st day exists.  If you want a trigger that always fires on the last day of the month - regardless of the number of days in the month, you should use ICronTrigger.
That’s it for today’s “New in Quartz.Net 2.0” post. Stay tuned for more, coming soon!


David said...

How do you schedule for it to fire every Sunday night at 12:03 am EST?

With this I can fire starting at a specific time but if I ever restart my application after this data it is automatically firing right when the app starts up.

start-time == 2011-06-27T03:06:00.0Z
end-time == 2099-05-04T18:13:51.0Z
repeat-interval == 1
repeat-interval-unit == Minute


J said...

David, use a cron trigger instead using this expression:
0 3 0 * * 1

Andrew Deakins said...

Hi great framework,

when i get time, will offer my services to help with this. I have
one question regarding the projects and that is does anybody experience the problem with the common logging and not being able to work without signed assemblies? just curious...

chispa said...
This comment has been removed by the author.
chispa said...

How do you schedule a job to execute everyxdays and repeat that job everyy hour/minutes for a day or for a specified time period.

chispa said...


please ignore my post above, I got my expression working now.

With regards to the CalendarTrigger though, is there a way to specify on which days the trigger should execute.

J said...


You have a few options:
1. You can use one of the calendars to exclude certain days from firing

2. Chain the jobs so that one job schedules other jobs using a custom schedule.

3. Create your own trigger.

4. Use several triggers and calendars to achieve a custom schedule.

Unfortunately there isn't a really easy way to do what you want.

chispa said...


For the first option, would I need to loop and calculate the days to eliminate from the schedule? Is there a recommended way of doing this? I am really new to the technology and is still trying to wrap my head around the library.

I will be looking at creating my own schedule as well..