* Cron Dialect
Quartz Scheduler (6–7 Fields)
* Quick Answer
Quartz Scheduler is the dominant Java job scheduling library, and its cron dialect extends standard 5-field syntax with a seconds field at position 1, an optional year field at position 7, and a rich set of special characters — L (last), W (nearest weekday), and # (Nth weekday). Quartz is also used as the basis for Spring @Scheduled cron expressions and several other JVM frameworks.
Field Reference
This dialect uses 6 or 7 fields. Fields are listed left to right as they appear in the expression.
| Position | Field | Range | Special Chars | Notes |
|---|---|---|---|---|
| 1 | Second | 0–59 | * , - / | Required. Most expressions use 0 here unless sub-minute precision is needed. |
| 2 | Minute | 0–59 | * , - / | |
| 3 | Hour | 0–23 | * , - / | 24-hour format. |
| 4 | Day of Month | 1–31 | * , - / ? L W | Use ? when specifying day-of-week. L = last day of month. W = nearest weekday. |
| 5 | Month | 1–12 | * , - / | Named values: JAN–DEC accepted. |
| 6 | Day of Week | 1–7 (SUN=1) | * , - / ? L # | 1=SUN, 2=MON … 7=SAT. Use ? when specifying day-of-month. L = last of that day in month. # = Nth occurrence. |
| 7 | Year | 1970–2099 | * , - / | Optional. Omit for most recurring schedules. Useful for one-time events. |
Special Characters
Quartz adds four characters beyond standard cron. The question mark (?) means 'no specific value' and must appear in either DOM or DOW — not both and not neither. L in the DOM field means the last day of the month; in DOW it means the last occurrence of that weekday (e.g. 6L = last Friday). W finds the nearest weekday to a given day-of-month (15W = nearest weekday to the 15th — could be Friday the 14th if the 15th is a Saturday). The hash (#) specifies the Nth weekday of the month — 2#3 means the third Monday.
Examples
Every day at noon
Midday batch jobs, lunchtime report generation, daily price updates.
At 10:15 AM on the last Friday of every month
Monthly end-of-period runs, last-Friday payroll processing, monthly compliance reports.
At midnight on 25 December every year
Annual events, Christmas-day data snapshots, year-specific one-time tasks.
Every 5 minutes starting at 2 PM, ending at 2:55 PM, daily
Windowed polling — only during peak business hours, saving resources overnight.
At 11:11 AM on 11 November every year
Novelty or commemorative triggers — demonstrates Quartz date precision.
At midnight on the last day of every month
Month-end close jobs, final billing runs, end-of-period archiving.
Keep this cron job monitored 24/7
UptimeRobot alerts you the moment a scheduled job stops responding. Free plan monitors up to 50 endpoints — no credit card required.
Common Gotchas
DOW is 1–7 with Sunday = 1, not 0
Unlike standard cron where Sunday = 0 (or 7), Quartz uses 1 = Sunday through 7 = Saturday. A standard cron '5' means Friday; in Quartz '5' means Thursday. Always verify DOW values when porting expressions between dialects.
? is required — never leave both DOM and DOW as *
In a Quartz expression you must put ? in exactly one of DOM or DOW. Using * in both is technically valid in some implementations but is considered ambiguous and triggers warnings or errors in others. The convention is: if you care about day-of-month, use ? in DOW and vice versa.
Seconds is the first field — standard expressions shift by one
The most common porting mistake is forgetting that Quartz prepends the seconds field. A standard '0 9 * * 1-5' (9 AM weekdays) becomes '0 0 9 ? * 2-6' in Quartz — note the leading 0 for seconds AND the DOW shift from 1-5 to 2-6 because Quartz DOW is 1-indexed from Sunday.
W finds the nearest weekday — it may cross month boundaries
1W means 'nearest weekday to the 1st'. If the 1st is a Sunday, W selects Monday the 2nd. However, W will never cross month boundaries — it will not go back to the last weekday of the previous month. This means if the 1st is a Saturday, it selects Monday the 3rd, not Friday the 30th.
Spring @Scheduled uses 6 fields only, no year
Spring Framework's @Scheduled annotation accepts Quartz-style 6-field cron expressions but does not support the 7th (year) field. Expressions with a year field will be rejected. Always use 6 fields in Spring.
Porting from Standard Cron
Converting from standard 5-field to Quartz: prepend a seconds field (usually 0), shift all field positions by 1, change DOW values from 0-based to 1-based (add 1 to each DOW number), and add ? to either DOM or DOW depending on which you intend to specify. Converting DOW 1-5 (Mon-Fri in standard) becomes 2-6 in Quartz.
How This Dialect Differs from Standard Cron
Quartz prepends a required Seconds field (0–59) making it a 6-field expression, and optionally appends a Year field for a 7-field form. It adds three special characters absent from standard cron: L (last day of month or last weekday), W (nearest weekday to a date), and # (Nth weekday of month). Day-of-month and day-of-week are mutually exclusive — exactly one must be ? (no-value). Standard cron's 5-field expressions cannot be used directly in Quartz without shifting every field one position to the right.
| Aspect | Standard Cron | Quartz |
|---|---|---|
| Field count | 5 fields | 6 or 7 fields |
| Seconds precision | No | Yes (field 1) |
| Year field | No | Optional / Required |
| Special chars beyond * , - / | None | L W # ? |
| DOM / DOW conflict rule | OR combination | Mutually exclusive — one must be ? |