hostdoc — offline cPanel/WHM/WHMCS support brain

← all runbooks

---
title: Cron job is not running
panel: cPanel / WHM
symptoms:
  - scheduled task has stopped
  - backup did not run
  - script runs manually but not on a schedule
  - cron job stopped working
  - scheduled email did not send
  - the nightly backup did not run
  - task is not running on time
  - wordpress cron not running
---

# Cron job is not running

## 1. Check whether the job ran at all

**Why:** the output distinguishes two different faults. No output at all
means the job is not being executed, which is a cron daemon or a
permissions problem. Output with an error in it means the job ran and
the script failed, which is a problem with the script. They are fixed in
completely different places.

**In cPanel:** Advanced > Cron Jobs. The Output column shows the last
result, and Edit > Edit Crontab shows the schedule.

**In the terminal:** `crontab -l -u <user>` for the account's schedule.

**Care:** this only reads.

- https://docs.cpanel.net/cpanel/advanced/cron-jobs/

## 2. Check that the command runs as the account, not as root

**Why:** a cron job runs as the account with no login shell profile
loaded. A command that works perfectly in a terminal often fails in cron
because it depends on the PATH or on an alias. This is the single most
common reason for "it works when I run it".

**In the terminal:** `sudo -u <user> -H /bin/bash -lc '<the command>'`
runs it the way cron would, with the account's environment.

**Care:** run it this way to test, not as root. Running it as root will
succeed and hide the problem.

## 3. Check the output and the exit status

**Why:** capture the output to a file so there is something to read.
Empty output with a non-zero exit status is a permission or path
problem. Empty output with a zero status usually means the script found
nothing to do, which is a different answer and needs to be given as one
rather than treated as a failure.

**In the terminal:** add `>> /home/<user>/cron-output.log 2>&1` to the
command and read the file after the next run.

**Care:** the output file counts against the account's disk quota.

## 4. Check the server's cron configuration

**Why:** if jobs across several accounts have stopped at once, it is the
server and not any one job. Each account's schedule is written by the
server's cron daemon, so a broken daemon stops everything while each
individual job still looks fine.

**In WHM:** Server Configuration > Configure cPanel Cron Jobs.

**In the terminal:** `systemctl status crond` and
`grep <user> /var/spool/cron/<user>`

**Care:** changing the server's cron configuration affects every
account. Do it in a maintenance window, not on a live call.

- https://docs.cpanel.net/whm/server-configuration/configure-cpanel-cron-jobs/