Almost every backend engineer, systems administrator, and DevOps practitioner has stared at a crontab schedule and paused for ten seconds just to remember which field comes first: is it minute or hour? Does Sunday start at 0 or 7? What happens if you specify both day of the month and day of the week?
Cron was written by Ken Thompson in the 1970s and remains the default task scheduler on Unix-like operating systems. Despite its age, its 5-field syntax trips people up regularly because the fields use different numerical ranges and subtle evaluation rules.
Here is a practical breakdown of how 5-part cron expressions work, where people make mistakes, and how to verify schedules before pushing them to production.
The Five Fields and Their Ranges
Standard system cron expressions consist of five space-separated fields:
┌───────────── minute (0 - 59) │ ┌───────────── hour (0 - 23) │ │ ┌───────────── day of the month (1 - 31) │ │ │ ┌───────────── month (1 - 12 or JAN - DEC) │ │ │ │ ┌───────────── day of the week (0 - 7, 0 and 7 are both Sunday) │ │ │ │ │ * * * * * - Minute (0–59): The exact minute past the hour. A
0means the top of the hour. - Hour (0–23): 24-hour notation.
0is midnight,12is noon,23is 11 PM. - Day of Month (1–31): The calendar day.
- Month (1–12 or JAN–DEC): Standard calendar months.
- Day of Week (0–7 or SUN–SAT): Days of the week. Note that
0and7both represent Sunday in standard Vixie cron.
Operators: How to Express Repetition
Instead of just single numbers, cron supports four primary operators:
1. Asterisk (*) — Every Value
An asterisk matches every possible value for that position:
* * * * * /usr/local/bin/heartbeat.sh # Runs every single minute of every hour of every day. 2. Comma (,) — Explicit List
Use commas to run a command at discrete intervals:
0 9,13,18 * * * /usr/local/bin/sync-inventory.sh # Runs at 09:00, 13:00, and 18:00 daily. 3. Hyphen (-) — Range
Use hyphens to define an inclusive span of values:
0 9 * * 1-5 /usr/local/bin/morning-brief.sh # Runs at 09:00, Monday through Friday. 4. Slash (/) — Step Values
Use slashes to skip intervals. The expression */15 in the minute column means "every 15 minutes":
*/15 * * * * /usr/local/bin/check-queue.sh # Runs at :00, :15, :30, and :45 of every hour. The Trap: Day of Month vs. Day of Week
This is the single most common bug in crontab configurations.
In most cron implementations, if both the Day of Month (field 3) and Day of Week (field 5) are specified with anything other than an asterisk (*), they are evaluated with an OR relationship, not an AND relationship.
For example, consider this schedule:
0 2 1 * 1 /usr/local/bin/monthly-report.sh A developer might intend this to mean: "Run at 2:00 AM on the 1st of the month, but only if it falls on a Monday."
In reality, cron will execute the command on:
- The 1st day of every month, AND
- Every Monday of the month.
If you need a command to run strictly when the 1st falls on a Monday, write the check inside your shell script or command wrapper:
0 2 1-7 * * [ "$(date +\%u)" -eq 1 ] && /usr/local/bin/monthly-report.sh Frequent Real-World Presets
Here are the schedules used most often in production environments:
- Top of every hour:
0 * * * * - Every day at midnight:
0 0 * * * - Every weekday morning at 8:30 AM:
30 8 * * 1-5 - Every Sunday at 3:00 AM (for database vacuums or backups):
0 3 * * 0 - Twice a day (noon and midnight):
0 0,12 * * * - First day of every month at midnight:
0 0 1 * *
Test Schedules Before Deploying
Mistakes in cron expressions can cause accidental database locks, overlapping queue workers, or missed reporting deadlines.
To make testing faster, I built a client-side Visual Cron Expression Generator and Explainer as part of Digital Vault PRO.
It translates any 5-field cron expression into plain English, shows the exact timestamps for the next five execution times, and lets you toggle minute, hour, day, and month presets interactively. Like all tools in the vault, it runs 100% in your browser using client-side JavaScript, with zero server requests.
You can also check out related developer utilities in the suite: