Quartz Cron Expression Description

CronTriggers are often more useful than SimpleTrigger, when you need jobs executed based on calendar-like schedules rather than simple intervals specified by SimpleTrigger.

CronTrigger Introduction

CronTrigger allows you to specify calendar-based schedules such as:

  • Every Friday at noon
  • Every weekday at 9:30 AM
  • Every 5 minutes between 9:00 AM and 10:00 AM on Mondays, Wednesdays, and Fridays

Like SimpleTrigger, CronTrigger has a startTime (when the schedule is in effect) and an optional endTime (when the schedule should cease).

Cron Expression Structure

A cron expression is a string consisting of 7 sub-expressions that describe individual details of the schedule:

Seconds Minutes Hours Day-of-Month Month Day-of-Week Year (Year field optional)

For example: "0 0 12 ? * WED" means execute every Wednesday at 12:00 PM

Field Specifications

Field Allowed Values Special Characters
Seconds 0-59 , - * /
Minutes 0-59 , - * /
Hours 0-23 , - * /
Day-of-Month 1-31 , - * ? / L W
Month 0-11 或 JAN-DEC , - * /
Day-of-Week 1-7 (1=星期日) 或 SUN-SAT , - * ? / L #
Year (optional) 1970-2099 , - * /

Special Character Descriptions

Character Meaning Example
* All values "*" in minutes field means every minute
? No specific value (only used in Day-of-Month and Day-of-Week fields) "?" in Day-of-Month field means ignore this field
- Range "10-12" in hours field means 10, 11, and 12 o'clock
, List multiple values "MON,WED,FRI" in Day-of-Week field means Monday, Wednesday, Friday
/ Increments "0/15" in seconds field means every 15 seconds starting from 0 seconds
L Last day (of month or week) "L" in Day-of-Month field means the last day of the month
W Nearest weekday "15W" in Day-of-Month field means the nearest weekday to the 15th of the month
# Nth weekday of the month "6#3" in Day-of-Week field means the third Friday of every month

Expression Examples

Execute every 5 minutes
0 0/5 * * * ?
Every hour on weekdays from 9 AM to 5 PM
0 0 9-17 ? * MON-FRI
12 PM on the last day of the month
0 0 12 L * ?
10:15 AM on the third Friday of every month
0 15 10 ? * 6#3
Every 30 seconds from 8 AM to 5 PM daily
0/30 * 8-17 * * ?
9 AM on the nearest weekday to the 15th of the month
0 0 9 15W * ?

Cron Expression Calculator

Next 10 Execution Times:

  • Enter expression and click calculate button...