Cron job not running

Diagnose a cron job that doesn’t seem to run: wrong schedule, relative paths, PHP binary, permissions, silent errors and overlapping runs.

TroubleshootingIntermediate2 min readUpdated

Does this match what you’re seeing?

  • A scheduled task never seems to happen
  • The script works in a browser but not from cron
  • Cron emails show errors

1. Capture output

Change the command so it writes everything to a log:

/usr/local/bin/php /home/USERNAME/path/to/script.php >> /home/USERNAME/cron-debug.log 2>&1

Wait for the next scheduled time and read the log. An empty log after the time has passed means cron didn’t run it; errors mean it ran and failed.

2. It didn’t run

  • Schedule: check the five fields. * 3 * * * runs every minute from 03:00 to 03:59, not once. Cron schedule syntax explained (with examples)
  • Server time zone differs from UK time.
  • The job was saved? Confirm it’s listed in Advanced Features then Cronjobs.

3. It ran and failed

Log showsFix
No such file or directoryUse full absolute paths for the script and anything it includes
php: command not foundUse the full PHP path Running PHP scripts from cron: paths, output and common mistakes
Failed opening requiredBuild include paths from __DIR__
Permission deniedScript and folders readable (644/755)
Wrong PHP version errorsCron may use a different PHP version than the website; call the specific binary

4. It runs but does nothing

  • The script depends on $_SERVER or $_GET values that don’t exist in cron
  • It exits early because a previous run’s lock file was never removed
  • Output is suppressed with >/dev/null, hiding the error

5. It runs too often or piles up

Add locking so overlapping runs exit. Running PHP scripts from cron: paths, output and common mistakes

Remove the debug log redirect when finished.

Popular

Tip: press / to search from any pageSee all results