Skip to content

Cron Job Not Running? How to Debug It on Linux and FreeBSD

Updated 4 December 2026

When a cron job does not run, check the schedule, the cron log, the environment, and the exit status in order. Most missed runs come down to a stopped daemon, a wrong crontab format, a short PATH under /bin/sh, or a hung previous run. Commands below were checked on Debian 13, Ubuntu 24.04 LTS, Fedora 44 (Cronie), and FreeBSD (15.1-RELEASE manuals and 16.0-CURRENT).

Start from what you see

Match what you see on the server to jump to the right step.

Scroll horizontally to see all columns.

What you seeLikely causeWhere to start
No cron log entry at the scheduled timeCron is stopped, the crontab was skipped, or the host timezone differsStep 1 and Step 2
A CMD log line exists, with no outputThe job failed under /bin/sh, short PATH, or wrong working directoryStep 3
An older process is still runningThe job is hung on I/O or holding a lockStep 4
The job finished, with empty or broken outputThe script exited non-zero without mail, or exited 0 after a partial failureStep 4 (output check)

Step 1: Check the host, user, and crontab file

First check which cron package runs on this host.

# Debian or Ubuntu
dpkg-query -W -f='${binary:Package}\t${Version}\n' cron

# Fedora, RHEL, AlmaLinux, or Rocky Linux (Cronie)
rpm -q cronie

# FreeBSD
freebsd-version -kru

The systemd unit is cron.service on Debian and Ubuntu. Fedora and RHEL-family hosts use crond.service. FreeBSD uses the base cron rc.d service (service cron status from a root shell or doas).

Next, check which Unix user owns the job. Do not assume it runs under your own SSH login.

JOB_USER=reports
getent passwd "$JOB_USER"
id "$JOB_USER"

Cron reads schedules from user crontabs and system crontabs. User crontabs have five time fields. System crontabs add a username field before the command.

Scroll horizontally to see all columns.

LocationHow to read itFormat
Your user crontabcrontab -l5 time fields, then command
Another user's crontabsudo crontab -u "$JOB_USER" -l5 time fields, then command
System crontab/etc/crontab5 time fields, username, then command
Package drop-in files/etc/cron.d/ (plus /usr/local/etc/cron.d/ on FreeBSD)5 time fields, username, then command

A personal crontab (crontab -e) has no username field:

17 2 * * * /srv/reports/bin/export

The same job in /etc/crontab or /etc/cron.d/report-export needs the username:

17 2 * * * reports /srv/reports/bin/export

If you paste a five-field line into /etc/cron.d/, cron reads /srv/reports/bin/export as the username and skips the job.

For /etc/cron.d/ files, check owner, mode, and file name:

# Linux
sudo stat -Lc 'path=%n type=%F owner=%U:%G mode=%a' /etc/cron.d/report-export

# FreeBSD (root shell)
stat -L -f 'path=%N type=%HT owner=%Su:%Sg mode=%Sp' /usr/local/etc/cron.d/report-export

Files in /etc/cron.d/ must belong to root and must not be group- or world-writable (0644 is standard). By default, Debian cron allows only ASCII letters, digits, underscores, and hyphens in /etc/cron.d/ file names. Files with dots like report.conf or report.bak are ignored. Passing -l to Debian cron switches to LSB naming rules (like run-parts --lsbsysinit). Cronie and FreeBSD allow dots, so leaving report.bak beside report runs the job twice.

Step 2: Check whether cron started the job

Check that the daemon is running

# Debian or Ubuntu
systemctl is-active cron.service
systemctl is-enabled cron.service

# Fedora or RHEL-family (Cronie)
systemctl is-active crond.service
systemctl is-enabled crond.service

# FreeBSD (root shell)
service cron status
sysrc cron_enable

If the daemon is stopped, read recent logs before restarting it so you keep the failure message. You do not need to restart cron after normal edits with crontab -e or in /etc/cron.d/. One exception on Cronie: editing the target of a symlinked file in /etc/cron.d/ without touching the symlink can miss inotify reload.

Check syntax, trailing newlines, and % signs

Make sure the last line ends with a newline character. Cron skips or rejects a final line that lacks a trailing newline.

On Linux, test a user crontab file without installing it:

# Debian or Ubuntu
crontab -n ./candidate.user.crontab

# Fedora Cronie
crontab -T ./candidate.user.crontab

Neither flag checks /etc/cron.d/ files, because those include the username column. FreeBSD crontab has no dry-run flag. Do not pass a file name to crontab on FreeBSD unless you mean to replace the active table.

Check the command for unescaped percent signs (%). Standard cron turns an unescaped % into a newline and sends the rest of the line to standard input, even inside quotes. date +%F runs date + and fails. Escape each percent sign as date +\%F, or move the command into a script file. You can test five-field schedules in the crontab cheat sheet and tester or compare examples in crontab syntax and examples.

Check the server timezone

# Linux
timedatectl status

# FreeBSD
date '+%Y-%m-%dT%H:%M:%S%z %Z'

Debian, Ubuntu, and FreeBSD evaluate schedules in the server's local timezone. Setting TZ=UTC in a crontab changes timestamps inside your script, not when cron starts the job. Only Cronie supports CRON_TZ=UTC to shift schedule times. On Cronie hosts, preview the next run time with cronnext:

TZ=UTC cronnext -t "$(date +%s)" ./candidate.user.crontab

Check the cron log for a CMD line

Query a short window around the expected run time:

# Debian or Ubuntu (use crond.service on Fedora/RHEL)
sudo journalctl -u cron.service --since "2026-08-08 01:55" \
  --until "2026-08-08 02:30" --no-pager

# FreeBSD (root shell)
grep reports /var/log/cron | tail -n 20

A matching line looks like CRON[4266]: (reports) CMD (/srv/reports/bin/export). That shows cron spawned /bin/sh for the entry. Cron does not log your script's output or exit code; see where to find and read cron logs.

Step 3: Run the command with cron's environment

An SSH session loads Bash or Zsh, your full PATH, and your current directory. Cron starts /bin/sh in the user's HOME directory with a stripped environment.

Reproduce that minimal environment from your terminal as the job user:

sudo -u reports -- env -i \
  HOME=/srv/reports \
  LOGNAME=reports \
  USER=reports \
  PATH=/usr/bin:/bin \
  SHELL=/bin/sh \
  /bin/sh -c 'cd /srv/reports && exec ./bin/export --dry-run'
printf 'exit=%s\n' "$?"

On Debian, Ubuntu, and Fedora, cron's default PATH is /usr/bin:/bin. FreeBSD's default login class sets /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin. When that test fails, check:

  1. Missing PATH directories (exit 127). Tools in /usr/local/bin, /opt, or ~/.local/bin fail unless you use full paths or set PATH= at the top of the crontab.
  2. Working directory. Cron starts in HOME, so ./config.yml fails unless you cd /srv/reports first or pass full paths.
  3. Bash syntax under /bin/sh. [[ ... ]], set -o pipefail, arrays, and source fail when /bin/sh is dash or POSIX sh. Put Bash code in an executable script starting with #!/usr/bin/env bash.
  4. Language version managers and virtualenvs. nvm, pyenv, and .venv live in .bashrc. Call /srv/reports/.venv/bin/python directly.
  5. File and directory permissions (exit 126), where the job user cannot traverse a parent directory or execute the script.
  6. Full disk, exhausted inodes, or kernel OOM kills stopping the process mid-run.

Check permissions, disk space, inodes, and OOM logs from items 5 and 6 with:

sudo namei -l /srv/reports/bin/export
sudo -u reports -- test -x /srv/reports/bin/export && echo executable
df -h / /tmp /srv/reports
df -i / /tmp /srv/reports
# Linux kernel OOM check (on FreeBSD, check /var/log/messages)
sudo journalctl -k --since "2 hours ago" --no-pager | grep -i 'killed process'

See the cron environment variables guide for PATH, SHELL, MAILTO, TZ, and secret-handling rules.

Step 4: Check for overlapping runs and bad output

Cron does not wait for the 02:00 run to finish before starting the 03:00 run. If an hourly sync takes 75 minutes or hangs on a socket, copies pile up and fight over the same files.

List matching processes for the job user (-a differs between Linux procps and FreeBSD pgrep):

# Linux
pgrep -a -u reports -f '^/srv/reports/bin/export([[:space:]]|$)'

# FreeBSD
pgrep -fl -u reports '^/srv/reports/bin/export([[:space:]]|$)'

If a PID is still running, check its start time (lstart) and elapsed time (etime):

ps -o user=,pid=,ppid=,lstart=,etime=,stat=,args= -p 1842

Wrap jobs that must not overlap with flock on Linux or /usr/bin/lockf on FreeBSD:

# Linux
0 * * * * /usr/bin/flock -n -E 75 /srv/reports/var/export.lock /srv/reports/bin/export

# FreeBSD
0 * * * * /usr/bin/lockf -t 0 -k /srv/reports/var/export.lock /srv/reports/bin/export

Do not rm a lock file while an old PID is still alive. The stuck process keeps its kernel lock on the open file descriptor. A third run can then create a new file at that path and overlap anyway.

Check both exit code and output

Save $? right after your command runs, before echo or logger overwrites it:

sudo -u reports -- /bin/sh -c 'cd /srv/reports && ./bin/export --dry-run'
rc=$?
printf 'exit=%s\n' "$rc"

Exit 0 only means the process reported no error. A pipeline like mysqldump | gzip without pipefail exits 0 even when mysqldump fails. An export script can also exit 0 after writing an empty file. Check that the output file exists, is non-empty, and parses cleanly before trusting the run.

Step 5: Get alerted when a job fails or misses a run

Logs only help after someone notices a missing report and logs into the server. Having the job send an outbound HTTP ping to Watchgoose turns missed or failed runs into alerts across your notification channels. Watchgoose does not install an agent or read local crontabs. It alerts when an expected signal does not arrive on time or reports a failure.

Ping only after validation passes

Save your check's ping URL in /srv/reports/config/watchgoose.curl (chmod 600, owned by reports). That keeps the URL out of crontab logs and ps output:

url = "https://watchgoose.com/ping/your-uuid-here"
fail
silent
show-error
connect-timeout = 5
max-time = 10
output = "/dev/null"

Chain the job, its output check, and curl with &&:

#!/bin/sh
/srv/reports/bin/export &&
    test -s /srv/reports/out/latest.csv &&
    /usr/bin/curl -q --config /srv/reports/config/watchgoose.curl

On FreeBSD, use /usr/local/bin/curl. Because && stops on any non-zero exit, Watchgoose is pinged only when both steps pass. A new check starts missed-run monitoring after its first successful ping.

Report start times and non-zero exit codes

To alert right away on non-zero exits (/1 to /255) and record duration (/start), save /usr/local/bin/monitor-run (chmod 755). Put https://watchgoose.com/ping/your-uuid-here on line 1 of /srv/reports/config/watchgoose.url (chmod 600):

#!/bin/sh
if [ "$#" -eq 0 ]; then
    printf 'usage: monitor-run command [arg ...]\n' >&2
    exit 64
fi

CURL=/usr/bin/curl # Use /usr/local/bin/curl on FreeBSD.
URL_FILE=${WATCHGOOSE_CONFIG:-/srv/reports/config/watchgoose.url}
url=
[ -r "$URL_FILE" ] && IFS= read -r url < "$URL_FILE"
url=${url%/}

ping_wg() {
    case "$url" in https://?*|http://?*) ;; *) return 0 ;; esac
    printf 'url = "%s/%s"\n' "$url" "$1" |
        "$CURL" -q -fsS -m 10 --retry 2 -o /dev/null --config - 2>/dev/null || :
}

ping_wg start
"$@"
rc=$?
ping_wg "$rc"
exit "$rc"

Call it from crontab -e:

17 2 * * * WATCHGOOSE_CONFIG=/srv/reports/config/watchgoose.url /usr/local/bin/monitor-run /srv/reports/bin/export

Sending /start begins a duration timer. The check's grace time also limits how long Watchgoose waits for completion after /start. See Measuring script run time, Signaling failures, and Reliability tips.

Frequently asked questions

Why did my @reboot cron job not run when the server booted?

@reboot runs once when the cron daemon starts during boot. Network interfaces, NFS mounts, Docker, or databases may not be ready yet. Use a systemd unit with After=network-online.target (or rc.d REQUIRE: on FreeBSD) when your job needs those services. On FreeBSD, service cron restart also runs @reboot entries again.

Can cron.allow or cron.deny block a user's crontab?

Yes. If /etc/cron.allow exists (or /var/cron/allow on FreeBSD), only listed users can install or run personal crontabs, and cron.deny is ignored. Otherwise, any user not listed in /etc/cron.deny (or /var/cron/deny) is allowed. System jobs in /etc/crontab and /etc/cron.d/ are not affected.

Why didn't editing /var/spool/cron/crontabs directly work?

Do not edit files under /var/spool/cron or /var/cron/tabs by hand. Edit personal crontabs with crontab -e (or sudo crontab -u user -e). That checks syntax, sets required ownership and file mode, and tells the daemon to reload the table.

What happens to a cron job when Daylight Saving Time springs forward?

When clocks jump from 01:59 to 03:00, Debian, Ubuntu, and Fedora Cronie run skipped fixed-time jobs (like 30 2 * * *) right after the jump, and do not re-run them during the autumn fall-back hour. FreeBSD does the same by default because /etc/defaults/rc.conf sets cron_dst="YES" (passing -s to cron); skipping spring-forward jobs or double-running fall-back jobs only happens if cron_dst="NO" is set in /etc/rc.conf. Wildcard or hourly jobs follow the new clock as usual, and running critical schedules in UTC avoids local DST jumps altogether.

Why doesn't cron run inside my Docker container?

Most container images run only your main CMD or ENTRYPOINT process as PID 1. They do not start a background cron daemon, even when /etc/cron.d/ files exist in the image. Use supercronic, trigger the container from the host or a Kubernetes CronJob, or read our Docker cron jobs guide.

Sources