What is a Quartz Cron Expression?
If you've used standard cron, Quartz cron is the same idea but with a few extras. It's the scheduling format used in Java Quartz Scheduler and Spring Boot. The big difference? It has 6 fields instead of 5 (it adds a seconds field) and comes with special characters that standard cron doesn't have.
Quick example: 0 0 9 ? * 2-6 means "every weekday at 9 AM, starting at 0 seconds".
The 6 Fields
A Quartz cron expression has 6 required fields (plus an optional 7th for year). Standard cron starts at minute - Quartz starts at second.
0-59
0-59
0-23
1-31
1-12
1-7
💡 Key difference: Standard cron uses 5 fields (no seconds) and numbers weekdays 0-6 (Sunday=0). Quartz uses 6 fields and numbers weekdays 1-7 (Sunday=1).
Quartz vs Standard Cron
| Standard Cron | Quartz Cron | |
|---|---|---|
| Fields | 5 (min, hr, day, month, weekday) | 6-7 (sec, min, hr, day, month, weekday, year) |
| Seconds | ❌ Not supported | ✅ First field |
| Weekday | 0-6 (Sunday=0) | 1-7 (Sunday=1) |
| ? character | ❌ Not available | ✅ Required in one day field |
| L, W, # | ❌ Not available | ✅ Last, weekday, nth |
| Used in | Linux crontab, GitHub Actions, K8s | Java Quartz, Spring Boot, Camunda |
⚠️ Common mistake: Pasting a 5-field Linux cron expression into a Spring Boot @Scheduled annotation. It won't work - you need to add 0 at the start for seconds and adjust the weekday numbers.
Try the Quartz Cron Tool
Parse any expression, build new ones with dropdowns, and see the next 3 run times - all in your browser.
Open Quartz Cron Generator →Special Characters
These are what make Quartz cron more powerful than standard cron. Standard cron supports *, ,, -, and / - Quartz adds four more.
? No specific value
Must be used in either day-of-month or day-of-week (but not both). It means "I don't care about this field". If you want to schedule by weekday, put ? in day-of-month. If you want to schedule by day of month, put ? in day-of-week.
Example: 0 0 9 ? * 2-6 - run at 9 AM on weekdays. The ? says "don't care which day of month it is".
L Last
In day-of-month: L means the last day of the month (could be 28, 29, 30, or 31). L-3 means 3 days before the last day.
In day-of-week: 6L means the last Friday of the month.
W Nearest weekday
Only works in day-of-month. 15W means "the nearest weekday to the 15th". If the 15th is a Saturday, it fires on Friday the 14th. If it's a Sunday, it fires on Monday the 16th. LW means the last weekday of the month.
# Nth weekday
Only works in day-of-week. 6#3 means "the 3rd Friday of the month" (Friday=6 in Quartz). 2#1 means "the 1st Monday". You can use 1-5 for the occurrence.
How the ? Character Works
flowchart TB
A["0 0 9 ? * 2-6"] --> B[Quartz Parser]
B --> C["Second: 0"]
B --> D["Minute: 0"]
B --> E["Hour: 9"]
B --> F["Day of Month: ? (skip)"]
B --> G["Month: * (every)"]
B --> H["Day of Week: 2-6 (Mon-Fri)"]
F -. ignored .-> I[Schedule]
C --> I
D --> I
E --> I
G --> I
H --> I
I --> J["Fires at 9:00:00 AM, Mon through Fri"]
One of the two day fields must always use ?. You can't constrain on both day-of-month and day-of-week at the same time.
Common Examples
Every day at noon. The classic. Second 0, minute 0, hour 12, every day.
Weekdays at 9 AM. Monday (2) through Friday (6). Remember, Sunday is 1 in Quartz.
Every 15 minutes. Health checks, polling, cache refresh.
Last day of every month at midnight. Month-end reports. The L handles the varying month lengths for you.
Third Friday of every month at midnight. The # picks the Nth occurrence of a weekday.
Last weekday of every month at midnight. Combines L and W - avoids weekends.
Converting Standard Cron to Quartz
Got a Linux cron expression and need to use it in Spring Boot? Here's how to convert:
0 9 * * 1-5 ← weekdays at 9 AM
# Step 1: Add seconds (0) at the start
0 0 9 * * 1-5
# Step 2: Change weekday numbers (0-6 → 1-7)
0 0 9 * * 2-6
# Step 3: Add ? to day-of-month
0 0 9 ? * 2-6
# Final Quartz expression
0 0 9 ? * 2-6 ← same schedule, Quartz format
Quartz Scheduler in a Spring Boot App
flowchart TB
subgraph SpringApp["Spring Boot Application"]
A["@Scheduled(cron='0 0 9 ? * 2-6')"] --> B[Quartz Scheduler Engine]
B --> C[Job Store]
C --> D[Thread Pool]
end
D --> E[Execute Job]
E --> F[Database Cleanup]
E --> G[Send Emails]
E --> H[Generate Reports]
style SpringApp fill:#f0f9ff,stroke:#0369a1,stroke-width:2px
style E fill:#fef3c7,stroke:#f59e0b,stroke-width:2px
In Spring Boot, you just annotate a method with @Scheduled and pass a Quartz cron expression. Spring handles the rest.
Where Quartz Cron Is Used
-
Java Quartz Scheduler: The original. Configure triggers with
CronScheduleBuilder.cronSchedule("0 0 12 * * ?"). -
Spring Boot: Use
@Scheduled(cron = "0 0 9 ? * 2-6")to schedule any method. - Apache Camel: Route scheduling with Quartz-format cron expressions.
- Camunda / Activiti: BPM workflow engines use Quartz cron for timer events.
Related
Quartz cron builds on top of standard cron concepts. If you're new to cron in general, start here:
- Cron Jobs Explained - How standard 5-field cron works on Linux
- Cron Expression Tool - Parse and build standard 5-field cron expressions
- Quartz Cron Tool - Generate and validate 6-field Quartz cron expressions