Cron Expression Guide: Crontab Syntax Explained
Log cleanup on a server, a database backup every night, a report pushed every weekday morning — on Linux, almost every "run this at a given time" requirement ends up in a crontab, and every crontab line is a cron expression. The same syntax shows up in Kubernetes CronJobs, Jenkins, GitHub Actions and Spring @Scheduled.
An expression is only five fields, but the mix of *, /, , and - is easy to misread. This guide explains the grammar first, then gives you a cheat sheet you can copy from, plus an online tool that translates any expression into plain language instantly.
Quick Start
- Open the Cron Explainer.
- Paste or type an expression into the "Cron (min hour day month dow)" box, e.g.
0 9 * * 1-5. - The "Natural language" panel below instantly shows a readable explanation (generated by the cronstrue library); invalid input shows "Could not parse this expression."
The tool translates expressions into readable meaning; for complex expressions, the library's interpretation is authoritative. After confirming the semantics, verify once in your actual scheduler.
The Five Fields in Detail
A standard crontab expression has five space-separated fields: minute hour day-of-month month day-of-week
* * * * *
│ │ │ │ └── day of week (0-7, both 0 and 7 mean Sunday)
│ │ │ └──── month (1-12)
│ │ └────── day of month (1-31)
│ └──────── hour (0-23)
└────────── minute (0-59)
Special Characters
| Character | Meaning | Example |
|---|---|---|
* |
Every value of the field | * in the minute field = every minute |
*/n |
Every n | */5 in minutes = every 5 minutes |
, |
List of values | 9,18 in hours = at 9:00 and 18:00 |
- |
Range | 1-5 in day-of-week = Monday to Friday |
a-b/n |
Every n within a range | 9-18/2 in hours = every 2 hours from 9 to 18 |
Note that */5 means "every 5 starting from the field's minimum", which in the minute field equals 0,5,10,…,55. To start a job at minute 2 of every hour, write 2-57/5, not */5.
Some implementations accept English abbreviations for month and day-of-week (JAN, MON, …), but they are less portable than plain numbers — stick to digits when the same schedule runs across platforms.
Cheat Sheet
| Expression | Meaning |
|---|---|
* * * * * |
Every minute |
*/5 * * * * |
Every 5 minutes |
0 * * * * |
At the top of every hour |
0 2 * * * |
Daily at 2:00 AM |
30 8 * * * |
Daily at 8:30 AM |
0 9 * * 1-5 |
Weekdays at 9:00 AM |
0 9 * * 1 |
Mondays at 9:00 AM |
0 3 * * 0 |
Sundays at 3:00 AM |
0 0 1 * * |
Midnight on the 1st of every month |
0 0 1 1 * |
Midnight on January 1st |
*/10 9-18 * * 1-5 |
Every 10 minutes between 9:00 and 18:59 on weekdays |
0 6,12,18 * * * |
Daily at 6:00, 12:00 and 18:00 |
The fastest way to build intuition: paste each line into the Cron Explainer and check it against the plain-language output.
The Three Most Common Mistakes
- Wrong field order: the five fields are always "minute hour day month weekday". Putting the hour first (
9 0 * * *) changes the meaning completely. - Out-of-range values: minute and hour start at 0;
60is invalid in the minute field, and the weekday field tops out at 7. - Misreading the
*/nbase:*/10always counts from 0; to shift the starting point you must use the "range/step" form.
Timezone and DST Pitfalls
crontab uses the server's local timezone — not UTC, and not your laptop's timezone. For cross-region deployments or shared servers, run timedatectl on the machine first, then write the expression.
Regions with daylight saving time have an extra trap: around 2 AM on switch days a schedule may run twice or not at all (the hour vanishes when clocks jump forward and repeats when they fall back). Keep critical jobs outside the 1:00–3:00 window, or schedule in UTC.
Relationship with Other Schedulers
- crontab: five fields, one-minute granularity.
- Quartz (Java): six to seven fields including seconds and an optional year, plus
?for "no specific value". - systemd timer: uses
OnCalendarsyntax (e.g.Mon..Fri 09:00:00) with second-level precision. - Kubernetes CronJob / cloud function triggers: mostly the five-field cron, but cloud platforms usually require an explicit timezone setting.
This tool validates standard five-field semantics; watch for field-count and special-character differences when migrating to other schedulers.
Notes & FAQ
Q: What if both "day of month" and "day of week" are set?
Most implementations treat them as OR: 0 0 1 * 1 runs "on the 1st of each month or every Monday", not "on the 1st only when it's a Monday". Set only one of them and leave the other as *.
Q: I need something to run every 90 seconds. Standard cron's finest granularity is one minute — there is no seconds field. Use Quartz's six-field format, a systemd timer, or a sleep loop inside your script.
Q: Does 0 0 31 2 * run on February 31st?
Never. February has no 31st, so this expression never fires, and some implementations refuse to save it. For month-end jobs, prefer "the 1st of the month" or a scheduler-specific extension such as Quartz's L (not standard cron).
Q: I edited the crontab but nothing happens.
Check in order: did you edit the right user's crontab (crontab -e)? Is the cron service running? Is % in the command escaped as \%? Are all paths in the script absolute? Cron's environment differs from your interactive shell — relative paths are the most common pitfall.
Related Tools
- Timestamp Converter — convert the next run time to a Unix timestamp for verification
- Date Calculator — compute date intervals to help plan schedules