Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

cron

Direct answer

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).

When to use this

Use it for recurring jobs, or when a cron job does not run or runs at the wrong time.

First 30 seconds

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.

Operational verification

crontab entry → cron daemon checks every minute → matching time → command runs as the user → output mailed or redirected

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it for recurring jobs, or when a cron job does not run or runs at the wrong time.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points

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.

Key checks
  • systemctl list-timers --all — systemd timers and next run
  • crontab -l -u <user> — a user's cron jobs
  • ls /etc/cron.d /etc/cron.daily — system cron jobs
  • journalctl -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. */35 in 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.
  • SHELL defaults to /bin/sh. MAILTO decides who gets mail, and an empty MAILTO sends none.

Examples

LineRuns
15 2 * * * /usr/local/bin/backupDaily at 02:15
*/10 * * * * /usr/local/bin/pollEvery 10 minutes
0 8-17 * * 1-5 /usr/local/bin/syncHourly from 08:00 to 17:00 on weekdays
30 4 1,15 * 5 /usr/local/bin/job04:30 on the 1st, the 15th and every Friday (the OR rule)
@reboot /usr/local/bin/warm-cacheOnce after each boot
0 3 * * * date +\%F >> /var/log/dates% must be escaped

Robust cron jobs

ProblemFix
"Works in my shell, not in cron"Set PATH in the crontab, or use absolute paths
Output is lostRedirect to a log, or set MAILTO
The job overlaps itselfflock -n /run/lock/job.lock command
Failures go unnoticedMonitor the exit status or a heartbeat (e.g. a push to monitoring)
Time zone confusioncron 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
cron linuxcrontab schedulingcron job troubleshootinglinux cron daemon
Embedded reference data

Quick lookup tables

cron operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for cron.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective statecron 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 verificationPin 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 chaincrontab source → cron daemon load → wall-clock/calendar match → user/environment setup → shell/command execution → exit/output → target state → workload verificationTrace requested/configured state through effective state to the observed workload result.
Failure boundarycron 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 evidenceCorrelated 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 verificationUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundarycron
Topic pathScheduling → cron
Runtime statecron 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 chaincrontab 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 boundarycron 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 ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?