A crontab line is five time fields followed by the command to run: minute hour day-of-month month day-of-week command. Each field takes a number in its own range — minute 0–59, hour 0–23, day-of-month 1–31, month 1–12, day-of-week 0–7 (both 0 and 7 mean Sunday) — or an * meaning “every value.” So 30 2 * * * reads “at minute 30 of hour 2, every day,” and */15 9-17 * * 1-5 reads “every 15 minutes, from 09:00 to 17:00, Monday through Friday.” Everything else in cron is a variation on those five fields plus a handful of operators.
What you’ll accomplish
- Read any crontab line out loud and know exactly when it fires.
- Write schedules using
*, ranges, lists, and steps without guessing. - Use the
@reboot,@daily, and@hourlyshortcuts correctly. - Edit, list, and manage your crontab with
crontab -e,-l, and-r. - Avoid the environment and day-of-week traps that make jobs silently not run.
Prerequisites
- A Linux (or other Unix-like) system with a cron daemon installed. Most distributions ship
cronieorvixie-cron; Debian and Ubuntu usecron. Confirm the service is active withsystemctl status cron(Debian/Ubuntu) orsystemctl status crond(RHEL/Fedora). - A regular user account. You do not need root for your own per-user crontab; you only need root to edit system-wide files under
/etc. - A terminal and a text editor. Cron uses whatever
$EDITOR(or$VISUAL) points to, falling back to a system default.
How it works
Every crontab entry is one line with six positions. The first five are time fields; the sixth is the command, which is passed to /bin/sh -c and can be as long as you like. The fields, in order:
A field matches when the current time matches the value you put there. An * matches every value, so a field left as * never restricts the schedule. The cron daemon wakes up once a minute, compares the current minute/hour/date against every line, and runs the command for each line that matches.
There is one rule that surprises almost everyone: the day-of-month and day-of-week fields are combined with OR, not AND. If you restrict both — for example 0 0 13 * 5 — cron runs the job on the 13th of the month and on every Friday, not only on Friday the 13th. AND-style “the 13th, but only if it’s a Friday” is not expressible in plain cron; you handle it with a date test inside the command instead. When you want a normal weekday schedule, leave day-of-month as * (as in 0 9 * * 1-5) so only the day-of-week field does the filtering.
Step-by-step
Match every value with *. An asterisk in a field means “any value this field can take.” * * * * * /path/to/job runs the command once every minute, forever, because no field restricts anything. You rarely want all five as * outside of testing, but a single * is how you say “don’t care about this field.”
*/2 * * * * /usr/local/bin/collect-metrics.sh
Runs collect-metrics.sh every 2 minutes, of every hour, every day. The */2 is a step (below); the four remaining * fields impose no other limit.
Pin an exact time with numbers. Put the specific minute and hour to fire once a day. Cron uses a 24-hour clock, so 2 PM is hour 14.
30 2 * * * /usr/local/bin/nightly-backup.sh
Reads “at minute 30 of hour 2 — 02:30 — every day, every month, every weekday.” This is the most common shape for a daily maintenance job.
Use ranges with a hyphen. A hyphen defines an inclusive range. In the day-of-week field, 1-5 is Monday through Friday (0/7 = Sunday, 1 = Monday, … 6 = Saturday).
0 9 * * 1-5 /usr/local/bin/send-daily-report.sh
Runs at 09:00 on Monday through Friday only. Weekends are skipped because Saturday (6) and Sunday (0) fall outside 1-5.
List discrete values with commas. A comma-separated list matches any of the values. It is not a range — you name each one.
0 8,12,17 * * * /usr/local/bin/poll-inventory.sh
Fires at 08:00, 12:00, and 17:00 daily. You can combine lists and ranges: 0 9-17/2 * * 1-5 means every two hours from 09:00 to 17:00 on weekdays.
Repeat at intervals with a step (/). A step runs the command every n units. */15 in the minute field is “every 15 minutes”; */6 in the hour field is “every 6 hours.” Steps start from the low end of the range, so */15 fires at :00, :15, :30, and :45.
*/15 * * * * /usr/local/bin/check-queue-depth.sh
Runs four times an hour, on the quarter-hour. Steps also apply to explicit ranges: 0-30/10 in the minute field means minutes 0, 10, 20, 30.
Use named-schedule shortcuts. Cron accepts a set of @ strings in place of all five time fields. They are easier to read and harder to get wrong:
@daily /usr/local/bin/rotate-logs.sh
@hourly /usr/local/bin/warm-cache.sh
@reboot /usr/local/bin/start-tunnel.sh
@hourly equals 0 * * * *, @daily (same as @midnight) equals 0 0 * * *, @weekly equals 0 0 * * 0, @monthly equals 0 0 1 * *, and @yearly (same as @annually) equals 0 0 1 1 *. @reboot is special: it runs once when the cron daemon starts after boot, not on any clock schedule. See the worked examples below for how a few common lines decode:
Edit your crontab with crontab -e. This opens your personal crontab in an editor and installs it when you save and exit. It validates the file before installing, so a syntax error is caught rather than silently ignored.
crontab -e
Add a blank line between entries for readability; anything after a # at the start of a line is a comment. Do not edit the raw spool file under /var/spool/cron by hand — always go through crontab -e so the daemon is notified of the change.
List and remove with crontab -l and crontab -r. Listing prints the current crontab to standard output; removing deletes it entirely.
crontab -l # print your crontab
crontab -l > my-cron.bak # back it up first
crontab -r # delete the whole crontab (no confirmation)
crontab -r is unforgiving — there is no prompt. Back up with crontab -l first. On many systems crontab -i -r asks before deleting; make that a habit.
Validate it works
The fastest way to prove a schedule fires is to have it write a timestamp somewhere you control, then watch that file. Add a temporary line that runs every minute:
* * * * * date >> /tmp/cron-test.log 2>&1
Wait a minute or two, then check the file:
tail -f /tmp/cron-test.log
You should see a new line appear each minute, for example Sat Jul 25 14:03:01 EDT 2026. Redirecting both stdout and stderr with >> file 2>&1 is what captures output; without it, output is mailed to the local user and usually lost.
You can also confirm from the daemon’s own logs. On systemd distributions:
journalctl -u cron --since "10 minutes ago" # Debian/Ubuntu
journalctl -u crond --since "10 minutes ago" # RHEL/Fedora
Or grep the syslog on systems that still write it:
grep CRON /var/log/syslog # Debian/Ubuntu
grep CROND /var/log/cron # RHEL/Fedora
Each execution logs a line like CRON[12345]: (alice) CMD (date >> /tmp/cron-test.log 2>&1). If you see the CMD line in the log but no output in your file, the schedule is correct and the problem is inside the command — a PATH or permissions issue, covered next. Remove the test line with crontab -e when you are done.
Troubleshooting
The job runs by hand but not from cron — almost always PATH or environment. Cron runs with a minimal environment: a short PATH (often just /usr/bin:/bin), no HOME beyond the default, and none of your shell profile. Commands that work in your interactive shell fail because their binary is not on cron’s PATH. Fix it by using absolute paths (/usr/local/bin/mytool, not mytool), or set PATH= at the top of the crontab:
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin
0 2 * * * mytool --run
A percent sign silently breaks the command. In a crontab, an unescaped % is turned into a newline and everything after the first % is fed to the command as standard input. This bites anyone using date format strings. Escape each one with a backslash:
0 1 * * * /usr/local/bin/snapshot.sh > /var/log/snap-\%Y\%m\%d.log 2>&1
Day-of-month plus day-of-week did not do what you meant. As covered in “How it works,” restricting both fields is OR, not AND. If your “first Monday of the month” or “Friday the 13th” job runs too often, that is why. Leave one of the two fields as *, or move the extra condition into the command with a test on date.
Output vanished and no one noticed the failure. By default cron mails a job’s output to the owning user through a local MTA. If no MTA is configured — common on minimal servers — that mail is discarded and failures are invisible. Either redirect output to a file you monitor (>> /var/log/myjob.log 2>&1), or set MAILTO=you@example.com at the top of the crontab so output is delivered somewhere you read.
crontab -e opens the wrong editor or will not save. Cron uses $EDITOR/$VISUAL; if that points to an editor you do not know how to exit, set your own before editing: export EDITOR=nano (or vim), then crontab -e. If the daemon reports a parse error on save, it will offer to re-edit rather than install a broken file — accept, and fix the flagged line.
Per-user vs system crontabs
Your crontab -e file has five time fields and a command. The system-wide files are slightly different: /etc/crontab and any file dropped into /etc/cron.d/ add a sixth position — the user to run as — between the day-of-week field and the command:
# /etc/cron.d/backup — min hour dom mon dow USER command
30 3 * * * root /usr/local/bin/system-backup.sh
The /etc/cron.daily, cron.hourly, and cron.weekly directories are simpler still: drop an executable script in, and run-parts runs it on that cadence with no time fields at all. Use /etc/cron.d/ for packaged or configuration-managed jobs, and your per-user crontab for anything scoped to one account.
When this is the wrong approach
Cron is the right tool for simple, recurring, wall-clock schedules. It is the wrong tool when you need any of the following. For calendar events that must survive downtime (run the missed job when the machine comes back), have dependencies on other services or mount points, or need structured, searchable logs, use systemd timers instead — they record every run in the journal and support Persistent=true for catch-up. See cron vs systemd timers for the decision and systemd timers vs cron for the migration mechanics. For sub-minute schedules, cron’s one-minute resolution is a hard floor — use a long-running service with its own timing loop, or a systemd timer with OnUnitActiveSec=. The authoritative references are the crontab(5) man page for the file format and the crontab(1) man page for the command.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.