DEV Community

quietpulse
quietpulse

Posted on • Originally published at quietpulse.xyz

Cron Job Not Running? A Practical Debug Guide for Production

If you are dealing with a cron job that should have run by now but did not, you need a real cron job not running debug process, not guesswork.

This is one of the most frustrating production problems because nothing looks obviously broken. Your app is up. The server responds. Dashboards are green. But some scheduled task, backup, sync, invoice generation, cleanup, email digest, simply did not happen.

The problem

A cron job not running is different from a cron job running and failing.

If the script starts and exits with an error, you usually have logs. If the job never runs at all, you often get almost nothing.

Typical symptoms:

  • a report did not arrive
  • backups were not created
  • invoices were not generated
  • cleanup stopped
  • a sync job did not run
  • the script works manually but not on schedule

Why it happens

1. The schedule is wrong

Cron syntax is easy to misread. Timezone confusion, wrong frequency, and editing the wrong crontab are common causes.

2. Cron runs in a different environment

Cron often has a reduced PATH, missing environment variables, and a different working directory.

/usr/bin/python3 /opt/app/sync.py
Enter fullscreen mode Exit fullscreen mode

Using absolute paths is much safer than relying on shell defaults.

3. The cron daemon is not active

Sometimes the scheduler itself is stopped, never started after reboot, or missing from the runtime environment.

4. Paths or permissions changed

Deployments can move scripts, virtualenvs, binaries, or log locations.

5. Output is discarded

This makes debugging much harder:

0 * * * * /opt/scripts/run-report.sh >/dev/null 2>&1
Enter fullscreen mode Exit fullscreen mode

Why it's dangerous

A cron job that does not run is dangerous because the damage is delayed:

  • stale data
  • missed backups
  • broken customer workflows
  • growing queues or temp files
  • billing gaps

The worst part is false confidence. Everything else may look healthy.

How to detect it

The best way to detect this is to monitor expected execution.

Ask:

  • was the job supposed to run?
  • did cron invoke it?
  • did it complete?
  • did it report success?

Heartbeat monitoring helps because a missing success signal becomes the alert.

Simple solution (with example)

A practical checklist:

  1. inspect the correct crontab
  2. confirm cron service is running
  3. use absolute paths
  4. capture output to a real log during debugging
  5. test under cron-like conditions
  6. add missed-run monitoring

Example:

#!/bin/bash
set -e

/usr/bin/python3 /opt/app/daily-report.py
curl -fsS https://quietpulse.xyz/ping/YOUR_JOB_TOKEN > /dev/null
Enter fullscreen mode Exit fullscreen mode

And in crontab:

0 * * * * /opt/scripts/daily-report.sh
Enter fullscreen mode Exit fullscreen mode

If the ping stops arriving, you know the job did not complete successfully on time.

Common mistakes

1. Debugging the script before confirming cron fired

If the scheduler never invoked the command, script-level debugging wastes time.

2. Checking the wrong user's crontab

Very common on shared systems.

3. Assuming manual success proves cron success

Your shell is not cron's shell.

4. Throwing output into /dev/null

That removes your fastest clue.

5. Ignoring timezone configuration

The job may be running at a different time than expected.

6. Fixing it once without adding monitoring

That is how the same incident repeats.

Alternative approaches

System logs

Good for confirming trigger attempts, but not enough on their own.

Wrapper scripts with exit reporting

Useful, but you still need missed-run detection.

Framework schedulers

Sometimes better for app-level visibility, but not always right for system jobs.

Heartbeat monitoring plus logs

Usually the most practical combination.

FAQ

How do I debug a cron job that is not running?

Check the schedule, correct user, cron service, command paths, and logs, then test under cron-like conditions.

Why does a cron job work manually but not automatically?

Because cron runs with a smaller environment, different PATH, and different assumptions.

How do I know whether cron actually triggered a job?

Check service status and cron-related logs, and add heartbeat monitoring for future runs.

What is the best long-term fix?

Use explicit paths, clear environment setup, useful logs, and alerts for missed execution.

Conclusion

When a cron job is not running, the fastest fix comes from a checklist, not guesswork.

Confirm the schedule, user, service, and paths, then add monitoring so the next missing run does not stay invisible.


Originally published at https://quietpulse.xyz/blog/cron-job-not-running-debug-guide

Top comments (0)