Use it for recurring jobs, or when a cron job does not run or runs at the wrong time.
cron
cron runs commands on a schedule from crontab entries: minute hour day-of-month month day-of-week command (e.g. 30 2 * * 1 /usr/local/bin/backup.sh).
1. crontab -l (or /etc/cron.d) — entry present and correct?
2. cron service running? systemctl status cron / crond.
3. Ran? journalctl -u cron --since today | grep <script>.
4. Fails → full paths, \%, executable, redirect output to a log.
5. Test the command as that user.
crontab entry → cron daemon checks every minute → matching time → command runs as the user → output mailed or redirected
For Scheduling → cron, continue with the first unproven Topic check: Identify cron implementation/service, crontab owner, exact entry, system/user crontab context and expected local trigger time. If that boundary is healthy, advance to the adjacent check: Validate loaded syntax and environment assignments such as SHELL, PATH, MAILTO and any CRON_TZ support before changing the command. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
crontab source → cron daemon load → wall-clock/calendar match → user/environment setup → shell/command execution → exit/output → target state → workload verification
Healthy evidence: daemon and crontab are active, the expected calendar match is observed, process identity/environment is correct and the job's target effect is verified.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Identify cron implementation/service, crontab owner, exact entry, system/user crontab context and expected local trigger time.
- Validate loaded syntax and environment assignments such as SHELL, PATH, MAILTO and any CRON_TZ support before changing the command.
- Correlate cron daemon logs with process start, stdout/stderr capture, exit handling and the exact non-interactive identity/environment.
- Reproduce with the same user/environment and verify the scheduled target effect at the next controlled trigger, including DST/timezone implications where relevant.
Verification chain. crontab source → cron daemon load → wall-clock/calendar match → user/environment setup → shell/command execution → exit/output → target state → workload verification
Step 3 Commands Verify boundary
crontab -e
crontab -l
grep CRON /var/log/syslog
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: entry is in the wrong user's crontab, daemon is inactive, newline/syntax/environment issues prevent load, command depends on interactive shell state, or DST/timezone causes unexpected trigger behavior.
It does not show behavior outside the captured host, clock/timezone, scheduler or time-daemon instance, identity/environment, source, trigger/measurement interval or workload scope. cron evidence is resolved only when the loaded entry is shown to match the intended wall-clock time, launch under the expected account/environment and produce the verified target effect.
Step 5 Common mistakes Narrow the fault
- Not redirecting output (mail spool fills or errors are lost).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Edit with crontab -e (user) or files in /etc/cron.d (with a user field). % must be escaped as \%. cron uses the system time zone. Output is mailed or lost unless redirected. Use crontab.guru or systemd-analyze calendar to check expressions.
systemctl list-timers --all— systemd timers and next runcrontab -l -u <user>— a user's cron jobsls /etc/cron.d /etc/cron.daily— system cron jobsjournalctl -u cron -u crond --since today— cron executions
ReferenceWhat it is1 section · depth on demand
Core model
Identify which cron implementation/daemon is active and which user owns the entry. Validate syntax and loaded crontab, then preserve timezone/DST context and inspect the daemon's trigger evidence. Reconstruct effective HOME, SHELL, PATH, cwd assumptions, redirections and command quoting before attributing a failed job to the application itself.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
cron evidence is resolved only when the loaded entry is shown to match the intended wall-clock time, launch under the expected account/environment and produce the verified target effect.
In depth
Writing reliable crontab entries
A crontab line holds five time fields followed by a command. In /etc/crontab and /etc/cron.d/, a user name comes before the command. The crontab(5) manual page specifies the details:
- Fields: minute 0–59, hour 0–23, day of month 1–31, month 1–12 or names, day of week 0–7 (0 and 7 are Sunday).
- Ranges are inclusive (
8-11), and lists use commas. - Steps (
*/2) are evaluated within their field.*/35in the minute field means minute 0 and 35 of each hour, not every 35 minutes. - If both day fields are restricted, the job runs when either matches.
- Unescaped
%turns into a newline. SHELLdefaults to /bin/sh.MAILTOdecides who gets mail, and an empty MAILTO sends none.
Examples
| Line | Runs |
|---|---|
15 2 * * * /usr/local/bin/backup | Daily at 02:15 |
*/10 * * * * /usr/local/bin/poll | Every 10 minutes |
0 8-17 * * 1-5 /usr/local/bin/sync | Hourly from 08:00 to 17:00 on weekdays |
30 4 1,15 * 5 /usr/local/bin/job | 04:30 on the 1st, the 15th and every Friday (the OR rule) |
@reboot /usr/local/bin/warm-cache | Once after each boot |
0 3 * * * date +\%F >> /var/log/dates | % must be escaped |
Robust cron jobs
| Problem | Fix |
|---|---|
| "Works in my shell, not in cron" | Set PATH in the crontab, or use absolute paths |
| Output is lost | Redirect to a log, or set MAILTO |
| The job overlaps itself | flock -n /run/lock/job.lock command |
| Failures go unnoticed | Monitor the exit status or a heartbeat (e.g. a push to monitoring) |
| Time zone confusion | cron uses the system time zone (CRON_TZ in some implementations) |
host$ crontab -l
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin
MAILTO=ops@example.net
15 2 * * * flock -n /run/lock/backup.lock /usr/local/bin/backup >> /var/log/backup.log 2>&1
*/10 * * * * /usr/local/bin/poll || logger -t poll "poll failed with $?"
host$ cat /etc/cron.d/report-cleanup
# m h dom mon dow user command
0 4 * * * reportapi /usr/local/bin/report-cleanup --days 30
host$ grep CRON /var/log/syslog | tail -2
host$ journalctl -u cron --since today | grep report-cleanup
Testing a job's environment
cron runs jobs with a minimal environment. To reproduce it, run env -i SHELL=/bin/sh PATH=/usr/bin:/bin HOME=$HOME /bin/sh -c '<command>'. That catches missing PATH entries and dependencies on variables from your interactive shell, before cron runs the job at 02:15.
Documented example, not captured output.
How it works at runtime
cron is part of Scheduling → cron. cron is the traditional periodic Linux scheduler that evaluates crontab entries against wall-clock fields and launches commands in a minimal non-interactive environment under a defined account.
Topic-specific state model. cron is the traditional periodic Linux scheduler that evaluates crontab entries against wall-clock fields and launches commands in a minimal non-interactive environment under a defined account.
Technical metadata. Host/VM, distribution/kernel/systemd/cron/chrony versions, wall-clock UTC/local time + numeric offset, monotonic/uptime context, timezone/tzdata, RTC/clocksource/virtualization, scheduler/unit/crontab owner, schedule expression/calendar/next+last trigger, effective user/group/environment/PATH/cwd, process/exit/output, time daemon/configured sources/selected source/stratum/reach/offset/delay/jitter/frequency/leap state, logs and original workload result.
Interpretation rule. - crontab -l contains an entry ≠ the cron daemon is running and evaluating it.
- A command works in an interactive shell ≠ cron has the same PATH, environment, TTY, cwd or credentials.
- Cron logged CMD ≠ the command completed successfully or changed the target state.
- A five-field schedule ≠ a fixed elapsed interval across DST/time changes; cron follows wall-clock calendar semantics.
Quick reference
cron syntax and practice:
# m h dom mon dow command
*/15 * * * * /usr/local/bin/check.sh >> /var/log/check.log 2>&1
30 2 * * 1-5 flock -n /run/backup.lock /usr/local/bin/backup.sh
@reboot /usr/local/bin/warmup.sh
MAILTO=ops@example.com
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
crontab -e; crontab -l -u alice
grep CRON /var/log/syslog; journalctl -u cron -u crond --since today
Pitfalls: minimal environment (PATH, no profile), % must be escaped (\%) in crontab lines, times are in the system time zone (CRON_TZ= supported by cronie), and output is mailed or lost unless redirected.
Limits and how it fails
Primary failure point. cron evidence is resolved only when the loaded entry is shown to match the intended wall-clock time, launch under the expected account/environment and produce the verified target effect.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
For scheduled work, choose cron or systemd timer semantics deliberately, including timezone, persistent catch-up and dependency/environment requirements. Remember that cron/systemd environments are not interactive shells and should declare paths/credentials explicitly.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Scheduling → cron. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.freedesktop.org/software/systemd/man/latest/systemd.timer.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
cron operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for cron.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | cron is the traditional periodic Linux scheduler that evaluates crontab entries against wall-clock fields and launches commands in a minimal non-interactive environment under a defined account. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin exact symptom + clock/trigger time → identify authoritative scheduler or time daemon → read back effective configuration/runtime state → reproduce or observe the expected event/source measurement → correlate identity/environment/offset/status with logs → change one demonstrated cause → read back stable state → repeat original scheduled or time-sensitive workload + regression check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | crontab source → cron daemon load → wall-clock/calendar match → user/environment setup → shell/command execution → exit/output → target state → workload verification | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | cron proof closes only when the loaded entry is shown to match the intended wall-clock time, launch under the expected account/environment and produce the verified target effect. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux scheduling/time evidence can establish this proof path: crontab source → cron daemon load → wall-clock/calendar match → user/environment setup → shell/command execution → exit/output → target state → workload verification | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured host, clock/timezone, scheduler or time-daemon instance, identity/environment, source, trigger/measurement interval or workload scope. cron proof closes only when the loaded entry is shown to match the intended wall-clock time, launch under the expected account/environment and produce the verified target effect. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven scheduling/time boundary: preserve the original timing and execution/source context, capture the adjacent scheduler/process or clock/source state, change only the demonstrated cause, then repeat the original scheduled or time-sensitive workload and regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
cron · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | cron |
|---|---|
| Topic path | Scheduling → cron |
| Runtime state | cron is the traditional periodic Linux scheduler that evaluates crontab entries against wall-clock fields and launches commands in a minimal non-interactive environment under a defined account. |
| Fast checks | - Identify cron implementation/service, crontab owner, exact entry, system/user crontab context and expected local trigger time. - Validate loaded syntax and environment assignments such as SHELL, PATH, MAILTO and any CRON_TZ support before changing the command. - Correlate cron daemon logs with process start, stdout/stderr capture, exit handling and the exact non-interactive identity/environment. - Reproduce with the same user/environment and verify the scheduled target effect at the next controlled trigger, including DST/timezone implications where relevant. |
| Verification chain | crontab source → cron daemon load → wall-clock/calendar match → user/environment setup → shell/command execution → exit/output → target state → workload verification Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | cron proof closes only when the loaded entry is shown to match the intended wall-clock time, launch under the expected account/environment and produce the verified target effect. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |