Skip to content
statance
MenuClose
← All troubleshooting guides

A cron job is not running

Linux

First confirm cron is running and whether it tried to run the job: grep CRON /var/log/syslog on Debian/Ubuntu, or journalctl -u cron (crond on RHEL). If it ran but failed, the cause is usually cron’s minimal environment — a different PATH, no shell profile, relative paths — so redirect output to a log file to see the real error.

Symptoms

  • A scheduled backup or script has not produced output
  • The script works when run by hand but not from cron
  • Nothing in the logs from the job

How to diagnose it

  1. Check the cron service

    The service is cron on Debian/Ubuntu and crond on RHEL family.

    systemctl status cron || systemctl status crond
  2. Check whether cron started the job

    Look for CMD lines with your command at the expected time.

    grep CRON /var/log/syslog | tail -20 journalctl -u cron --since today # or -u crond
  3. Capture the job’s output

    Add a redirect so errors are kept.

    */5 * * * * /opt/scripts/backup.sh >> /var/log/backup-cron.log 2>&1
  4. Reproduce cron’s environment

    Runs the script with an empty environment like cron.

    env -i SHELL=/bin/sh PATH=/usr/bin:/bin HOME=$HOME /opt/scripts/backup.sh

Common causes and fixes

Command not found because of PATH

Use absolute paths in the script, or set PATH at the top of the crontab.

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Unescaped % in the command

cron treats % as a newline. Escape it as \% (common with date +%F).

0 2 * * * tar czf /backup/site-$(date +\%F).tgz /var/www

Script not executable or wrong owner

Make it executable and check which user’s crontab it is in.

chmod +x /opt/scripts/backup.sh

File in /etc/cron.d has wrong format or name

Files in /etc/cron.d need a user field and names without dots; files in /etc/cron.daily are skipped by run-parts if they contain a dot.

Wrong schedule or timezone

Cron uses the system timezone (timedatectl). Double-check the five fields.

Prevent it happening again

  • Add a Statance heartbeat monitor: the job pings a URL when it finishes, and you are alerted when the ping does not arrive.
  • Append /fail to the heartbeat URL on error so failures alert immediately.

Set it up: Cron job heartbeats monitoring.

FAQ

Where are cron logs on Ubuntu?

In /var/log/syslog (grep CRON) or journalctl -u cron. Job output is mailed to the user unless redirected.

Why does my script work manually but not in cron?

Cron runs with a minimal environment and a different PATH, and without your shell profile. Use absolute paths and set required variables in the script.

Related guides

Get alerted before this becomes an outage.

Install the agent in one line. Statance watches CPU, memory, disk and services, and its AI assistant helps find the cause.