Cron Job Log Guide: How to Find and Read Cron Logs
A backup job can appear healthy while producing no useful evidence at all. The scheduler may record that it launched the command, while the command itself fails under cron's restricted environment, writes output to an unexpected location, or sends diagnostics to a mail system nobody monitors. When the restore is needed, the only remaining clue may be a zero-byte dump and a log file that rotated away the evidence.
A reliable cron job log is therefore more than a place to grep for CRON. It's an operational record that connects schedule, user, command, output, exit status, duration, retention, and alerting. The practical path is to locate the correct logging backend, capture stdout and stderr explicitly, preserve rotated evidence, and monitor successful completion rather than assuming that a scheduler entry proves the work finished.
Table of Contents
- When the Silent Cron Job Becomes Your Problem
- Where Cron Logs Live on Major Linux Distributions
- Capturing stdout and stderr from Cron Jobs
- Reading and Parsing Cron Job Logs Effectively
- Log Rotation and Centralization for Cron Output
- Monitoring and Alerting on Cron Job Failures
- Pre-Flight Checklist and Common Questions
When the Silent Cron Job Becomes Your Problem
A nightly database backup can run for weeks without raising an alarm. The cron daemon may write an execution line to the system log, suggesting that the schedule works. During a restore drill, the dump may be empty because the command failed, while its useful error output went nowhere.
A scheduler record confirms an attempted launch. It does not confirm that the backup completed, transferred its files, or created a valid artifact. The cron job log is the first forensic layer: it provides the execution timestamp, account, process marker, and command that an investigator can correlate with application output and the resulting files.
Cron schedules commands; it does not validate their business result. The crontab manual documents environment variables, output delivery and scheduling syntax. Explicitly define the environment and output path instead of relying on an interactive shell profile.
Practical rule: A
CMDentry proves an attempted launch. It doesn't prove application success.
Clean tutorials often assume that logging is enabled and that every host uses a familiar file path. Production systems violate both assumptions. journald may operate alongside rsyslog or be the only configured log store, a minimal cloud image may have rsyslog masked, a user crontab may lack a working mail transport agent, and logrotate may already have removed the period under investigation. A missing line can indicate a stopped daemon, an unconfigured logging sink, an unreadable file, a filtered facility, or a job that was never installed.
Treat the investigation as an evidence pipeline:
- Locate the scheduler record: Identify whether the host uses
/var/log/syslog,/var/log/cron, another syslog destination, or journald. - Capture command output: Redirect stdout and stderr instead of relying on cron mail.
- Reconstruct history: Search current and compressed rotated files, then correlate execution lines with application output.
- Preserve evidence: Set an intentional rotation and retention policy for custom logs.
- Alert on state: Detect failures, excessive duration, and missing successful heartbeats.
For a scheduled command that does not run at all, the cron jobs not running guide offers a focused troubleshooting reference. The operating requirement is straightforward: logs must let a responder determine what ran, under which account, at what time, with what result, and whether the expected work happened.
Where Cron Logs Live on Major Linux Distributions
The first diagnostic mistake is treating a distribution-specific path as a universal contract. Debian and Ubuntu commonly route cron messages through /var/log/syslog, while RHEL-family systems commonly use /var/log/cron. Some hosts expose the same facility through journald, and a dedicated /var/log/cron.log exists only when an administrator has configured it.
Start by identifying the daemon and its service state:
command -v cron || command -v crond
systemctl status cron 2>/dev/null || systemctl status crond
systemctl is-enabled cron 2>/dev/null || systemctl is-enabled crond
On Debian or Ubuntu, inspect the traditional sink:
sudo grep -i CRON /var/log/syslog | tail -50
sudo tail -f /var/log/syslog | grep --line-buffered CRON
On RHEL, CentOS, Rocky, or similar systems, use:
sudo grep -i CRON /var/log/cron | tail -50
sudo tail -f /var/log/cron
If neither file exists, check the general message log and the logging configuration:
sudo grep -i cron /var/log/messages 2>/dev/null | tail -50
sudo grep -R 'cron\.\*' /etc/rsyslog.conf /etc/rsyslog.d 2>/dev/null
systemctl status rsyslog
The presence of a rule isn't enough. A masked or stopped rsyslog service can leave the expected file empty even though cron is active. Disk pressure also matters:
df -h /var /var/log
sudo ls -l /var/log/syslog /var/log/cron /var/log/messages 2>/dev/null
Journald changes the search strategy
On systemd hosts, query the service or process directly:
sudo journalctl -u cron
sudo journalctl -u crond
sudo journalctl _COMM=cron
sudo journalctl _COMM=crond
sudo journalctl -u cron -f
If the host has rebooted, inspect the effective journal configuration including drop-ins. Storage=auto uses persistent storage when /var/log/journal exists; Storage=volatile uses /run/log/journal. Retention and access permissions can also limit visible history. The journald configuration manual describes these choices. Inspect available boots and disk use:
sudo journalctl --list-boots
sudo journalctl --disk-usage
A volatile journal won't preserve older records after a restart. The operator should also check whether journald forwards messages to syslog, rather than assuming both stores contain identical data.
The practical locations and commands differ by platform:
| Distribution | Log File or Sink | Primary Read Command | Init System |
|---|---|---|---|
| Debian or Ubuntu | /var/log/syslog, or journald |
grep CRON /var/log/syslog, journalctl -u cron |
systemd with rsyslog or journald |
| RHEL family | /var/log/cron, or journald |
grep CRON /var/log/cron, journalctl -u crond |
systemd with rsyslog or journald |
| Arch Linux | journald by default, optional syslog destination | journalctl _COMM=crond |
systemd |
| Minimal systemd host | journald, possibly volatile | journalctl _COMM=cron or journalctl _COMM=crond |
systemd |
Confirm cron is installed, the expected entry is installed under the right account, and the daemon is running. Then check scheduling/timezone and logging destinations. An active daemon without a matching log line does not by itself prove a logging fault: the job may not be due or correctly installed.
Capturing stdout and stderr from Cron Jobs
A cron command can launch successfully yet lose the evidence you need. Permission errors, missing binaries, authentication failures, and pipeline diagnostics may never reach a usable log. Cron can attempt to mail output, but that path depends on a correctly configured local mail transfer agent.
The following examples are user crontab entries installed with crontab -e. Files under /etc/cron.d require an additional username field. Provision the log directory and files for the executing account with restrictive permissions; a failed redirection prevents the command from starting. Use explicit append redirection:
30 2 * * * /usr/local/bin/backup.sh >> /var/log/cronjobs/backup.log 2>&1
>> keeps earlier runs, and 2>&1 combines stderr with stdout. Separate the streams when operators need a normal output file and a prominent error file:
30 2 * * * /usr/local/bin/backup.sh >> /var/log/cronjobs/backup.log 2>> /var/log/cronjobs/backup-errors.log
Have the script print timestamps at meaningful milestones, or put the command behind a wrapper that records start, completion, duration, and exit status. That creates a stable evidence boundary instead of turning the crontab line into an unreadable shell program.
A wrapper creates an evidence boundary
#!/usr/bin/env bash
set -uo pipefail
umask 077
job_name=${1:?job name required}
shift
case "$job_name" in
''|*[!A-Za-z0-9_-]*) printf 'Invalid job name\n' >&2; exit 64 ;;
esac
[ "$#" -gt 0 ] || { printf 'Command required\n' >&2; exit 64; }
log_dir=${CRON_LOG_DIR:-/var/log/cronjobs}
# Provision this directory and its ownership before running the job.
exec 3>>"$log_dir/$job_name.log" || exit 73
started=$(date +%s)
run_id="$started-$$"
printf '%s job=%s run=%s event=start\n' \
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$job_name" "$run_id" >&3
"$@" >&3 2>&1
status=$?
finished=$(date +%s)
printf '%s job=%s run=%s event=finish exit_code=%s elapsed_seconds=%s\n' \
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$job_name" "$run_id" \
"$status" "$((finished-started))" >&3
exit "$status"
The wrapper preserves the child’s exit status and captures both output streams without shell tracing. It does not catch SIGKILL, power loss or a hung process; a start record without a finish record needs investigation or a missing-heartbeat alert. Elapsed seconds use wall-clock time and can be distorted by clock adjustments. Prevent overlapping runs or correlate interleaved output by run ID.
The crontab entry stays readable:
MAILTO=""
30 2 * * * /usr/local/bin/cronrun.sh database-backup /usr/local/bin/backup.sh
Do not enable set -x for normal operation: it can expose credentials and arguments. The wrapper’s pipefail setting does not propagate into a child shell script; that script must handle its own pipelines. MAILTO="" disables cron mail, so retain an independent failure/missing-run alert.
For Python commands, the Python logging to file guide covers application-side file logging. MAILTO can supplement the evidence path when local mail is configured and monitored, but it should not be the only record of a run.
Reading and Parsing Cron Job Logs Effectively
A syslog line is human-readable, but it isn't a complete job record. A typical entry contains a timestamp, hostname, process tag, process identifier, user account, and command marker:
Mar 10 02:30:01 app01 CRON[1842]: (backup) CMD (/usr/local/bin/backup.sh)
The CMD line says cron launched the command. An application log or wrapper status record is needed to establish completion and exit status. Some cron implementations also emit error text when a child fails, but the exact wording varies, so a parser shouldn't depend on one message format.
Extract the evidence that survives format changes
For classic files, begin with narrow searches:
sudo grep -h 'CRON.*CMD' /var/log/cron /var/log/syslog 2>/dev/null
sudo grep -h 'CRON.*backup.sh' /var/log/cron /var/log/syslog 2>/dev/null
sudo grep -h 'CRON.*backup.sh' /var/log/cron.1 /var/log/syslog.1 2>/dev/null
sudo zgrep -h 'CRON.*backup.sh' /var/log/cron*.gz /var/log/syslog*.gz 2>/dev/null
zgrep matters because the relevant execution may live in a compressed archive. The absence of a CMD entry around an expected time is evidence that cron didn't record a launch, but it doesn't identify the cause by itself. Check the crontab, access controls, daemon state, and time configuration before concluding that the schedule was skipped.
A simple field extraction pattern can make a line easier to ingest:
sudo awk '
/CRON/ {
timestamp = $1 " " $2 " " $3
host = $4
tag = $5
sub(/:$/, "", tag)
print timestamp "," host "," tag "," $0
}' /var/log/cron /var/log/syslog 2>/dev/null
The simple extraction above is diagnostic output, not a fully escaped CSV format. Classic syslog timestamps often omit a year and timezone; other configured formats can differ. Preserve the original line. Use the CSV export below for classic RFC 3164-style lines, or structured journal output when available.
Journald offers structured metadata
Journal queries can emit JSON, which is safer for downstream processing:
sudo journalctl -u cron -o json --no-pager |
jq -r '[
.__REALTIME_TIMESTAMP,
._HOSTNAME,
._UID,
._PID,
.PRIORITY,
.MESSAGE
] | @csv'
The key distinction is between journal metadata and message content:
| Field | Syslog Example | Journalctl JSON Key | Meaning |
|---|---|---|---|
| Timestamp | Mar 10 02:30:01 |
__REALTIME_TIMESTAMP |
Event time recorded by the logging system |
| Host | app01 |
_HOSTNAME |
Machine that emitted the record |
| Process | CRON[1842] |
_COMM, _PID |
Scheduler process identity |
| Account | (backup) in MESSAGE |
_UID may identify the process user |
User context, depending on implementation |
| Event | CMD (/path/job) |
MESSAGE |
Cron's textual action record |
| Severity | Often implicit in syslog view | PRIORITY |
Journal priority value |
Duration isn't normally present in a scheduler line. It must come from wrapper output, application logs, or correlated start and finish records. Exit codes follow shell conventions, where 0 means success and a non-zero value indicates failure, but cron's own launch record may not expose that value. Operators should avoid inferring success from the absence of an error line.
A compact CSV export across current and rotated files can preserve raw evidence:
{
printf 'source,timestamp,host,process,message\n'
for file in /var/log/cron /var/log/cron.1 /var/log/syslog /var/log/syslog.1; do
[ -r "$file" ] || continue
awk -v source="$file" '
/CRON/ {
ts=$1 " " $2 " " $3
host=$4
process=$5
sub(/:$/, "", process)
line=$0
gsub(/"/, "\"\"", line)
printf "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n", source, ts, host, process, line
}
' "$file"
done
} > cron-evidence.csv
Log Rotation and Centralization for Cron Output
Rotation is a control, not a cleanup chore. An appended cron application log grows until the filesystem or the operator's evidence window becomes the failure. Distribution defaults vary, and a custom /var/log/cronjobs/ directory won't be protected unless a matching logrotate rule exists.
Inspect the active policy before changing it:
sudo ls -l /etc/logrotate.d
sudo grep -R -nE 'cron|syslog|messages' /etc/logrotate.conf /etc/logrotate.d 2>/dev/null
sudo logrotate -d /etc/logrotate.conf
For the wrapper’s one append-only file per job, a rule can rotate historical files. This example assumes a pre-existing backup user/group owns the logs; replace that account with the actual job owner:
/var/log/cronjobs/*.log {
daily
rotate 14
compress
delaycompress
missingok
notifempty
su backup backup
create 0600 backup backup
}
rotate 14 retains up to 14 rotated files; with notifempty, it does not guarantee exactly 14 calendar days of history. Choose retention for your investigation needs. This rule is not a cleanup policy for one-file-per-run directories. The logrotate manual explains rotation, creation and compression behavior. The wrapper holds an open descriptor, so a run crossing rotation keeps writing to the renamed file; coordinate rotation with job duration. delaycompress only postpones compression until the next rotation.
logrotate -d performs a diagnostic dry run and does not rotate files or verify post-rotation writes. First test a copied configuration and sample log in a disposable directory, then schedule any real rotation outside active jobs:
sudo logrotate -d /etc/logrotate.d/cronjobs
sudo find /var/log/cronjobs -type f -ls
If rsyslog writes the active file, restarting it can interrupt collection if performed carelessly. Validate configuration first, then use the service's documented reload behavior and inspect the queue afterward. Journald has its own retention controls, so logrotate won't manage journal storage.
Central stores preserve context
Local files are useful for immediate shell access, but they disappear with ephemeral containers and can be lost during host replacement. Containerized jobs should write to stdout and stderr, allowing the runtime or collector to ship records centrally with fields such as job name, container or pod identifier, host, and status. File-only output inside a disposable container is an avoidable evidence gap.
Common shipping paths include:
- Rsyslog forwarding: Use
imjournalto read journald andomfwdto send records to a remote syslog endpoint, preserving facility and severity where possible. - Journald forwarding: Enable the appropriate forwarding behavior when rsyslog is the collection layer, then verify that messages aren't duplicated or filtered.
- Filebeat: Target
/var/log/cron*and dedicated cron output files, using JSON decoding when the wrapper emits one record per line. - Fluent Bit: Tail host-mounted cron files or container stdout, adding Kubernetes metadata before forwarding.
The logrotate complete guide covers the broader mechanics of rotation. Centralization should happen before compression or deletion, and the central record should retain the original timestamp, hostname, account, job name, exit status, and message body. Otherwise a searchable archive can still lack the context needed to prove which scheduled execution failed.
Monitoring and Alerting on Cron Job Failures
A log line is passive evidence. It doesn't wake an operator, distinguish a successful backup from a merely launched process, or detect a schedule that never ran. Production monitoring needs an explicit success signal, an exit status, a runtime boundary, and an absence condition.
The wrapper can emit a machine-readable completion record:
#!/usr/bin/env bash
set -uo pipefail
: "${JOB_LOG:?Set JOB_LOG to a writable output file}"
command -v jq >/dev/null || exit 69
started=$(date +%s)
/usr/local/bin/backup.sh >>"$JOB_LOG" 2>&1
status=$?
finished=$(date +%s)
finished_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)
jq -nc \
--arg job "database-backup" \
--arg timestamp "$finished_at" \
--argjson exit_code "$status" \
--argjson elapsed_seconds "$((finished-started))" \
'{job:$job,timestamp:$timestamp,exit_code:$exit_code,elapsed_seconds:$elapsed_seconds}'
exit "$status"
This is an alternative complete script for a collector that reads JSON from stdout. Set JOB_LOG, install jq, and keep its execution environment explicit. It returns the backup status after emitting a record. A logging failure must also be monitored; neither wrapper proves that a zero-exit backup is restorable.
Three workable alerting patterns
Heartbeat monitoring uses a unique URL that the job calls only after success. If the call never arrives within the expected window, the monitor raises a missed-run alert. This is simple and effective for scripts that already have a clear final step, but the endpoint call must occur after validation, not immediately after process launch.
Prometheus, Pushgateway and Alertmanager can monitor suitable service-level batch jobs. Pushgateway exposes the latest pushed metrics; Prometheus scrapes and stores their history, evaluates alerts, and sends them to Alertmanager. Avoid per-run identifiers and clean up obsolete series. Prometheus recommends considering the textfile collector for machine-related batch jobs instead of using Pushgateway indiscriminately.
Nagios or Icinga can run checks against expected execution windows and inspect a status file or timestamp. This fits environments that already use plugin-based checks, although each job may require bespoke state handling.

Operational distinction: A successful scheduler launch, a successful process exit, and a valid business result are three separate checks.
Absence detection deserves equal attention. A daily schedule that hasn't produced a success record within its expected window should alert even when no failure line exists. A backup wrapper can exit successfully after creating an unusable file, so a post-run validation, such as checking expected contents or transfer completion, should precede the heartbeat.
Fivenines task monitoring expects a success ping within the configured schedule and grace period. A script can also report explicit failure using its documented failure endpoint. Send success only after validating the output; a failed ping can reflect a network issue even if the backup succeeded. Keep local evidence and a missing-ping alert. The alert setup guide covers the response workflow.
Logs are one part of the evidence. Use the cron job verification guide to check the schedule, execution environment and expected result alongside the captured output.
Pre-Flight Checklist and Common Questions
A cron deployment is ready only when its execution path and evidence path have both been tested. The following checks catch most silent failures before the schedule matters:
- Daemon: Run
systemctl is-active cronorsystemctl is-active crond, then confirm the correct service name for the distribution. - Backend: Verify
/var/log/syslog,/var/log/cron, orjournalctlreceives a test event. Check rsyslog status and journal persistence where applicable. - Environment: Use absolute binary paths, define
PATH, set the expected shell and working directory, and validate the job under the same account. - Output: Redirect both streams with
>> ... 2>&1, add timestamps, and confirm ownership and permissions on the destination. - Overlap: Use
flockor an equivalent lock so a slow run doesn't overlap the next invocation. - Rotation: Use
logrotate -dfor configuration diagnosis; verify actual rotation and subsequent writes with a disposable test fixture. - Alert: Test a deliberate non-zero exit and a missing-success condition before relying on the monitor.

Common questions
Why did cron run the command but create no job output? The crontab may discard output, redirect it to /dev/null, or send it to an unavailable mail system. Check the scheduler line, then add explicit stdout and stderr redirection.
How can an operator tell whether cron is installed? Use command -v cron or command -v crond, then inspect the matching systemd unit with systemctl status.
What's the difference between /var/log/cron and /var/log/syslog? They're distribution and configuration choices. RHEL-family hosts commonly separate cron messages into /var/log/cron, while Debian and Ubuntu commonly place them in /var/log/syslog.
How can a schedule be tested without waiting for its normal time? Temporarily install a frequent test entry that writes to a dedicated temporary log, verify the result, and restore the intended schedule immediately afterward.
Why does MAILTO sometimes produce nothing? Cron may invoke local delivery, but the host might lack a functioning mail transfer agent or the mailbox may not be monitored. File or centralized logging is more dependable for forensic output.
Fivenines provides cron job tracking based on post-success ping signals, with alerts and workflow automation for missed or late executions alongside infrastructure monitoring. Teams responsible for silent backups or unattended maintenance can visit Fivenines to evaluate a centralized way to turn cron execution evidence into actionable task state.