Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
Python & Django

Making Sure the Overnight Job Actually Runs

Last updated:

Silent failure is the default

A scheduled job that stops running produces no error. The report is not sent, the sync does not happen, and nobody notices until a number looks wrong days later.

Alert on completion, not just failure. A job that never started looks identical to a job with nothing to do.

What every scheduled job needs

  1. Idempotency — safe to rerun
  2. Overlap protection — a slow run must not be joined by the next
  3. A completion record that is monitored
  4. A time limit, so a stuck job does not run forever
  5. Logging of what was processed, not just that it ran

Design for restart

  • Process in batches with progress recorded
  • A restarted job resumes rather than starting again
  • One bad record does not stop the run
  • Failed records quarantined with the reason

A nightly job that fails at ninety per cent and restarts from nothing will eventually stop completing at all.

Watch the clock

IssueGuard
Daylight savingSchedule in UTC
Jobs overlappingLocking
Duration growingMonitor and investigate
Several heavy jobs at onceStagger the schedule
Month-end spikesTest at realistic volume

Duration growing steadily over months usually means a query scanning a growing table, and it is worth investigating before it exceeds its window.

Make manual runs possible

There will be occasions when a job needs running for a specific date, or rerunning after a fix. Building that in from the start is trivial; adding it under pressure is not.

A command that accepts a date range covers most of these situations.

Frequently asked questions

How do we know a job ran?

A completion record with an expected window, monitored, alerting if it does not appear.

What if it takes longer than its interval?

Locking prevents overlap. Investigate the duration — growing runtime usually indicates an unindexed query on growing data.

Should scheduled work use a queue?

Frequently a good pattern — the schedule enqueues and workers process. That gives retries and observability for free.

How do we handle catch-up after downtime?

A manual run accepting a date range. Design it in rather than improvising it during an incident.

Keep reading

Overnight job that might not have run?

If you cannot tell without checking manually, that is the gap. Completion alerting is a small fix.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

Custom Software DevelopmentWeb DevelopmentMachine Learning