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
      • 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

Cron Triggers

Use a CronTrigger for a schedule that recurs on calendar notions rather than at the exact intervals of a SimpleTrigger: "every Friday at noon", "every weekday at 9:30 am", "every 5 minutes between 9:00 am and 10:00 am on every Monday, Wednesday and Friday". Like a SimpleTrigger, it has a start time, when the schedule comes into force, and an optional end time, when it stops.

Cron Expressions

A cron expression is 6 or 7 whitespace-separated fields: seconds, minutes, hours, day-of-month, month, day-of-week and an optional year. Each field takes a value, a list, a range, an increment, or a special character allowed for that field. 0 0 12 ? * WED means "every Wednesday at 12:00 pm".

The Cron Expression Reference has the field table, every special character (*, ?, -, ,, /, L, W, # and the H hash token that spreads load across triggers), and worked examples.

Example Cron Expressions

More are in the API documentation for CronTrigger.

ExpressionFires
0 0/5 * * * ?every 5 minutes
10 0/5 * * * ?every 5 minutes, 10 seconds after the minute (10:00:10 am, 10:05:10 am, …)
0 30 10-13 ? * WED,FRIat 10:30, 11:30, 12:30 and 13:30 every Wednesday and Friday
0 0/30 8-9 5,20 * ?every half hour between 8 am and 10 am on the 5th and 20th of every month: 8:00, 8:30, 9:00 and 9:30, not 10:00

Some schedules need more than one trigger, such as "every 5 minutes between 9:00 am and 10:00 am, and every 20 minutes between 1:00 pm and 10:00 pm". Create two triggers and register both for the same job.

Building CronTriggers

Build a CronTrigger with TriggerBuilder (the main properties) and its WithCronSchedule extension method (the CronTrigger-specific properties). CronScheduleBuilder.Create(cronExpression) builds the same schedule on its own, to hold in a variable or share between triggers. To compose the expression string in code, see Building cron expressions programmatically.

Assembled inline, with no expression string (4.3):

ITrigger weekdays = TriggerBuilder.Create()
    .WithIdentity("nightly", "group1")
    .WithCronSchedule(cron => cron.AtTime(new TimeOnly(3, 0)).OnWeekdays())  // "0 0 3 ? * MON-FRI"
    .ForJob("myJob", "group1")
    .Build();

ITrigger everyTenMinutes = TriggerBuilder.Create()
    .WithIdentity("poll", "group1")
    .WithCronSchedule(cron => cron.Every(TimeSpan.FromMinutes(10)))          // "0 0/10 * ? * *"
    .ForJob("myJob", "group1")
    .Build();
  • The lambda configures a fresh CronExpressionBuilder; see Building cron expressions programmatically.
  • Every counts on the clock: every ten minutes is :00, :10, :20. It takes an interval that divides the minute, hour or day evenly. For any other interval, or one counted from the trigger's start, use WithSimpleSchedule(interval).

Every other minute, between 8am and 5pm, every day:

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger3", "group1")
    .WithCronSchedule("0 0/2 8-17 * * ?")
    .ForJob("myJob", "group1")
    .Build();

Daily at 10:42 am:

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger3", "group1")
    .WithCronSchedule("0 42 10 ? * *")
    .ForJob(myJobKey)
    .Build();

or:

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger3", "group1")
    .WithCronSchedule("0 42 10 * * ?")
    .ForJob("myJob", "group1")
    .Build();

Wednesdays at 10:42 am, in a time zone other than the system's default:

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger3", "group1")
    .WithCronSchedule("0 42 10 ? * WED", x => x
        .InTimeZone(TimeZones.FindById("Central America Standard Time")))
    .ForJob(myJobKey)
    .Build();

or, with the schedule built first so that several triggers can share it:

CronScheduleBuilder schedule = CronScheduleBuilder
    .Create("0 42 10 ? * WED")
    .InTimeZone(TimeZones.FindById("Central America Standard Time"));

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger3", "group1")
    .WithCronSchedule(schedule)
    .ForJob(myJobKey)
    .Build();

TimeZones.FindById is TimeZoneInfo.FindSystemTimeZoneById plus any registered resolvers. With the TimeZoneConverter plugin added, a Windows id resolves on Linux.

Once per day at a hash-derived time between midnight and 7:59 AM, spreading load across triggers:

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("nightly-cleanup", "maintenance")
    .WithCronSchedule("0 H H(0-7) * * ?")
    .ForJob("cleanupJob", "maintenance")
    .Build();

CronTrigger Misfire Instructions

Misfires are explained in More About Triggers. CronTrigger's instructions are on the CronTriggerMisfireInstruction enum, whose API documentation describes each:

InstructionAfter a misfire
SmartPolicythe default on every trigger; CronTrigger treats it as FireAndProceed
CronTriggerMisfireInstruction.FireAndProceedfires once as soon as the scheduler is back, then continues from the next scheduled time
CronTriggerMisfireInstruction.DoNothingskips the missed firings and waits for the next scheduled time
CronTriggerMisfireInstruction.IgnoreMisfiresfires every missed firing, as fast as the scheduler can, until the schedule has caught up

The behaviour is in CronTriggerImpl.UpdateAfterMisfire. Set the instruction on the cron schedule (WithCronSchedule):

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger3", "group1")
    .WithCronSchedule("0 0/2 8-17 * * ?", x => x
        .WithMisfireInstruction(CronTriggerMisfireInstruction.FireAndProceed))
    .ForJob("myJob", "group1")
    .Build();
Help us by improving this page!
Last Updated: 10/6/26, 2:13 PM
Contributors: Marko Lahma, Claude Opus 5.5
Prev
Simple Triggers
Next
RecurrenceTrigger