How to read a cron expression
A cron expression is a line of fields separated by spaces. Each field says when the job may run, and the job runs whenever all the fields match the current time. Linux crontab uses five fields:
┌───────── minute (0-59)
│ ┌─────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌─── month (1-12 or JAN-DEC)
│ │ │ │ ┌─ day of week (0-7 or SUN-SAT; 0 and 7 are Sunday)
│ │ │ │ │
30 9 * * MON-FRI → at 09:30 on weekdays Spring and Quartz add a seconds field at the front, and Quartz allows an optional year field at the end.
Special characters
| Symbol | Meaning | Example |
|---|---|---|
* | Every value | * * * * * every minute |
, | A list of values | 0 9,13,17 * * * |
- | A range | 0 9-17 * * * |
/ | A step: every n-th value | */10 * * * * every 10 minutes |
? | No specific value (Spring, Quartz); use it in the day field you don't care about | 0 0 12 ? * MON |
L | Last: last day of the month, or with a weekday, the last such weekday | L, L-2, 5L |
W | The weekday (Mon–Fri) nearest a given day of the month | 15W, LW |
# | The n-th weekday of the month | 6#3 third Friday in Quartz |
Crontab vs Spring vs Quartz
- Linux crontab has 5 fields and no seconds. It also accepts shortcuts such as
@daily,@weeklyand@reboot. - Spring (
@Scheduled(cron = "…")) has 6 fields starting with seconds. Days of the week run from 0 or 7 (Sunday) to 6 (Saturday), like crontab, andL,Wand#are supported. - Quartz has 6 or 7 fields, and one of day-of-month and day-of-week must be
?. Days of the week are numbered differently: 1 is Sunday and 7 is Saturday. Writing day names (MON,FRI) avoids mistakes when you move a schedule between tools.
A crontab trap: day of month and day of week together
In Linux crontab, if both day fields are restricted, the job runs when either matches. 0 0 13 * 5 runs on every 13th and on every Friday, not just on Friday the 13th. If one of the two fields starts with * (for example */2), both must match instead. The explainer follows these rules, and the run list shows you the real result.
Time zones
Cron runs in the time zone of the machine or container, which on servers and in Kubernetes is usually UTC. Switch Show times in to UTC to see run times the way your server will. In Spring you can pin a zone with @Scheduled(cron = "…", zone = "Asia/Kolkata"), and Kubernetes CronJobs accept a timeZone field.
Frequently asked questions
What does */5 mean in cron?
*/5 means every 5th value of that field, starting from the lowest one. In the minute field that is minutes 0, 5, 10 … 55, so */5 * * * * runs every five minutes.
How do I run a cron job every 30 seconds?
Linux crontab can't go below one minute. Spring and Quartz have a seconds field, so */30 * * * * * runs every 30 seconds. With plain crontab, a common workaround is two entries, one of them starting with sleep 30;.
Why didn't my cron job run at the time I expected?
The most common causes are the server running in UTC instead of your local time zone, day-of-week numbering that differs between tools (Quartz counts Sunday as 1), and the crontab rule that runs a job when either day field matches. Paste your expression here and compare the next run times with what you expected.
What is the difference between 0 and 7 for day of week?
In crontab and Spring both 0 and 7 mean Sunday. In Quartz the range is 1 to 7, where 1 is Sunday and 7 is Saturday.
Is my expression sent anywhere?
No. Parsing and the run-time calculation happen in your browser.