Quartz.NETQuartz.NET
Home
Features
Blog
Discussions
NuGet
GitHub
Home
Features
Blog
Discussions
NuGet
GitHub
  • Getting Started

    • Overview
    • Quartz 4 Quick Start
    • Tutorial
      • Using Quartz
      • Jobs And Triggers
      • More About Jobs & JobDetails
      • Job Data
      • More About Triggers
      • Querying Jobs and Triggers
      • Simple Triggers
      • Cron Triggers
      • RecurrenceTrigger
      • Time and TimeProvider
      • Trigger and Job Listeners
      • Scheduler Listeners
      • Job Execution Middleware
      • Job Stores
      • Configuration, Resource Usage and Building a Scheduler
      • Building a Scheduler Without a Host
      • Clustering
      • Execution Groups
      • Node Affinity (Preferred Node)
      • Testing
      • Compile-Time Checks
      • Declaring Jobs with Attributes
      • Delegate Jobs
    • Configuration Reference
    • JSON Configuration
    • Cron Expression Reference
    • Multi-Tenancy
    • Comparison
    • Frequently Asked Questions
    • Best Practices
    • Before You Go Live
    • Operating a Cluster
    • Log Events
    • Tenancy Patterns
    • Database Schema
    • Database Schema Changes
    • Migration Guide
    • Troubleshooting
    • API Documentation
  • How To's
    • One-Off Job
    • Rescheduling Jobs
    • Backfill
    • Retrying Failed Jobs
    • Pausing with a Reason
    • Job Continuations
    • Overlap Policy
    • Progress and Execution Logs
    • Job Outcomes
    • Multiple Triggers
    • Job Template
    • Running Quartz under Aspire
    • Quartz.NET with Wolverine
    • Coming from Hangfire
    • Coming from TickerQ
    • Embedding Quartz in a Library
    • Running under an External Leader Election
    • Publishing Trimmed and Native AOT
    • Extending Quartz: what is open, what is closed, and how to ask
    • A Job Store of Your Own
    • A Driver Delegate for a New Database
    • Persisting a Custom Trigger Type
    • A Lock Handler of Your Own
  • Packages

    • Quartz Core Additions

      • Jobs
      • Serialization (System.Text.Json)
      • JSON Serialization
      • Plugins
    • Integrations

      • Aspire Integration
      • ASP.NET Core Integration
      • HTTP API
      • HTTP Client
      • Dashboard
      • Dashboard Agent
      • Hosted Services Integration
      • Microsoft DI Integration
      • Multiple Schedulers with Microsoft DI
      • Observability
      • Redis Lock Handler
      • TimeZoneConverter Integration
      • Weasel Schema Management
    • 3rd Party Plugins for Quartz
  • Quartz 3.x

    • Getting Started

      • Quartz 3 Quick Start
      • Tutorial
        • Using Quartz
        • Library Overview
        • Jobs And Triggers
        • More About Jobs
        • More About Triggers
        • Execution Groups
        • Node Affinity (Preferred Node)
        • Simple Triggers
        • Cron Triggers
        • RecurrenceTrigger
        • Trigger and Job Listeners
        • Scheduler Listeners
        • Job Stores
        • Tuning the Scheduler
        • Configuration, Resource Usage and SchedulerFactory
        • Advanced (Enterprise) Features
      • Configuration Reference
      • JSON Configuration
      • Multi-Tenancy
      • Frequently Asked Questions
      • Best Practices
      • Tenancy Patterns
      • Troubleshooting
      • API Documentation
      • Database Schema
      • Database Schema Changes
      • Migration Guide
      • Miscellaneous Features
    • How To's

      • One-Off Job
      • Multiple Triggers
      • Job Template
      • Using the CronTrigger
      • Rescheduling Jobs
    • Packages

      • Quartz Core Additions

        • Dashboard
        • Jobs
        • Serialization (System.Text.Json)
        • Serialization (Newtonsoft Json.NET)
        • Plugins
      • Integrations

        • ASP.NET Core Integration
        • Hosted Services Integration
        • Microsoft DI Integration
        • Multiple Schedulers with Microsoft DI
        • OpenTelemetry Integration
        • OpenTracing Integration
        • Redis Lock Handler
        • TimeZoneConverter Integration
      • 3rd Party Plugins for Quartz
  • Old Releases

    • Quartz 2.x
      • Quartz 2 Quick Start
      • Tutorial
        • Lesson 1: Using Quartz
        • Lesson 2: Jobs And Triggers
        • Lesson 3: More About Jobs & JobDetails
        • Lesson 4: More About Triggers
        • Lesson 5: SimpleTrigger
        • Lesson 6: CronTrigger
        • Lesson 7: TriggerListeners and JobListeners
        • Lesson 8: SchedulerListeners
        • Lesson 9: JobStores
        • Lesson 10: Configuration, Resource Usage and SchedulerFactory
        • Lesson 11: Advanced (Enterprise) Features
        • Lesson 12: Miscellaneous Features of Quartz
        • CronTrigger Tutorial
      • Configuration Reference
      • Migration Guide
      • API Documentation
    • Quartz 1.x
      • Tutorial
        • Lesson 1: Using Quartz
        • Lesson 2: Jobs And Triggers
        • Lesson 3: More About Jobs & JobDetails
        • Lesson 4: More About Triggers
        • Lesson 5: SimpleTrigger
        • Lesson 6: CronTrigger
        • Lesson 7: TriggerListeners and JobListeners
        • Lesson 8: SchedulerListeners
        • Lesson 9: JobStores
        • Lesson 10: Configuration, Resource Usage and SchedulerFactory
        • Lesson 11: Advanced (Enterprise) Features
        • Lesson 12: Miscellaneous Features of Quartz
      • API Documentation
  • License

Quartz.NET 3.x

These are the documents for the 3.x line, which is maintained. Quartz.NET 4.x is the current release; the migration guide says what changed and what to do about it.

More About Triggers

There are several trigger types for different scheduling needs. They share the options below.

Common Trigger Attributes

Every trigger type has a TriggerKey for its identity, plus these properties, set with the TriggerBuilder when you build the trigger:

  • JobKey: the identity of the job to execute when the trigger fires.
  • StartTimeUtc: when the trigger's schedule first takes effect, as a DateTimeOffset. Some trigger types fire at the start time; for others it only marks when the schedule starts being followed. A trigger stored in January with the schedule "every 5th day of the month" and StartTimeUtc set to April 1st first fires months later.
  • EndTimeUtc: when the trigger's schedule stops. A trigger with the schedule "every 5th day of the month" and an end time of July 1st fires for the last time on June 5th.

The properties that need more explanation follow.

Priority

When many triggers fire at the same time (or the thread pool has few worker threads), Quartz.NET may not have the threads to fire them all at once. Set a trigger's priority to decide which ones get the free threads first. If N triggers fire at the same time and only Z worker threads are free, the Z triggers with the highest priority run first.

  • The default priority is 5.
  • Any integer is allowed, positive or negative. A larger number is a higher priority: 7 beats 5.

Tips

Priorities are only compared when triggers have the same fire time. A trigger scheduled to fire at 10:59 will always fire before one scheduled to fire at 11:00.

Tips

When a trigger's job needs recovery, the recovery is scheduled with the same priority as the original trigger.

Misfire Instructions

A misfire happens when a persistent trigger misses its firing time because the scheduler was shut down or the thread pool had no free thread. Each trigger type has its own misfire instructions. The default is a 'smart policy' instruction, whose behavior depends on the trigger type and configuration.

When the scheduler starts, it finds persistent triggers that have misfired and updates each according to its misfire instruction. Learn the misfire instructions of the trigger types you use; their API documentation explains them, and the lesson for each trigger type covers them.

Applying a misfire instruction consults the trigger's calendar. Since 3.22.4, a calendar that throws there fails that trigger alone:

  • The trigger keeps its fire time, the exception is logged, and its misfire is handled again on a later pass. The rest of the pass, or of the completion that unblocked it, carries on.
  • The failure counts toward quartz.jobStore.maxConsecutiveFireFailures at most once per quartz.jobStore.misfireThreshold, so a calendar that keeps throwing parks its trigger ERROR after five failures that far apart. A misfire handled starts the count again.
  • Resuming a trigger handles the misfires it accrued while paused. ResumeTrigger, ResumeTriggers, ResumeJob, ResumeJobs and ResumeAll log a calendar's exception rather than throw it, and resume the trigger as it was. Read GetTriggerState rather than catching.

Execution Groups

A trigger can have an execution group: a tag describing the resource needs of its job (e.g. "batch-jobs", "high-cpu"). Each scheduler node can limit how many threads a group may use concurrently, so resource-intensive jobs cannot starve other work.

Set it with TriggerBuilder:

TriggerBuilder.Create()
    .WithIdentity("myTrigger")
    .WithExecutionGroup("batch-jobs")
    // ...
    .Build();

See the Execution Groups tutorial for configuration and usage. To control which cluster node runs a trigger, see the Node Affinity tutorial.

Calendars

A calendar (an ICalendar implementation) associated with a trigger excludes blocks of time from the trigger's schedule. Associate it when the trigger is stored in the scheduler. For instance, a trigger fires a job every weekday at 9:30 am, and a calendar excludes the business's holidays.

A calendar can be any serializable object implementing ICalendar:

namespace Quartz
{
 public interface ICalendar
 {
  string Description { get; set; }

  ICalendar CalendarBase { set; get; }

  bool IsTimeIncluded(DateTimeOffset timeUtc);

  DateTime GetNextIncludedTimeUtc(DateTimeOffset timeUtc);

  ICalendar Clone();
 }
} 

Calendars can block out time as narrow as a millisecond, but you will usually block out whole days. HolidayCalendar does that.

Instantiate calendars and register them with the scheduler's AddCalendar(..) method. Fill a HolidayCalendar with the days to exclude using its AddExcludedDate(DateTime date) method. Several triggers can use the same calendar instance:

Calendar Example

    HolidayCalendar cal = new HolidayCalendar();
    cal.AddExcludedDate(someDate);
    
    await sched.AddCalendar("myHolidays", cal, false);
    
 ITrigger t = TriggerBuilder.Create()
  .WithIdentity("myTrigger")
  .ForJob("myJob")
  .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(9, 30)) // execute job daily at 9:30
  .ModifiedByCalendar("myHolidays") // but not on holidays
  .Build();

 // .. schedule job with trigger

 ITrigger t2 = TriggerBuilder.Create()
  .WithIdentity("myTrigger2")
  .ForJob("myJob2")
  .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(11, 30)) // execute job daily at 11:30
  .ModifiedByCalendar("myHolidays") // but not on holidays
  .Build();

	// Use H (hash) to spread triggers across time instead of a fixed schedule.
	// The trigger identity is used as the hash seed, so each trigger fires at a unique time.
	ITrigger t3 = TriggerBuilder.Create()
		.WithIdentity("myTrigger3")
		.ForJob("myJob3")
		.WithCronSchedule("0 H H(9-17) * * ?") // execute at a hash-derived time during business hours
		.ModifiedByCalendar("myHolidays")
		.Build();

    // .. schedule jobs with triggers

The triggers above fire daily, and skip any firing that falls in a period the calendar excludes. The next lessons cover building triggers in detail.

A calendar is your code, and it can throw. Since 3.22.4 a calendar that throws fails only its own trigger's fire: the rest of the batch fires, the trigger is left as it was, and the failure counts toward quartz.jobStore.maxConsecutiveFireFailures (default 5), after which the trigger is set ERROR. Up to 3.22.3 it stranded what was around it:

Store3.22.3 and earlier
RAMJobStoreThe whole fire batch or acquisition pass; a serial job's other triggers stayed Blocked
JobStoreTX, JobStoreCMTThe completion was retried until shutdown, and the job stayed BLOCKED

The Quartz.Impl.Calendar namespace has more ICalendar implementations.

Help us by improving this page!
Last Updated: 10/19/26, 11:45 PM
Contributors: Marko Lahma, Claude Opus 5.5
Prev
More About Jobs
Next
Execution Groups