Back to Blog
Software

The Nightly Settlement Didn't Run Again: Designing Batch Job Scheduling, Reprocessing, and Monitoring

Nightly batch jobs fail without anyone noticing until the next morning. This post covers the essentials of batch operations design: dependency-based scheduling, idempotency and checkpoint restart, monitoring for missed runs, delays, and abnormal counts, and reprocessing runbooks.

POLYGLOTSOFT Tech Team2026-10-117 min read8
Batch JobsJob SchedulerReprocessingSystem OperationsMaintenance

Batch Jobs Fail Quietly

When a screen breaks, users tell you right away. When the settlement batch that runs at 2 a.m. fails, nobody notices. The problem only surfaces the next morning, when the sales team asks why yesterday's revenue is missing.

The cause is usually structural.

  • Scattered cron entries: Jobs are spread across the crontabs of three or four servers, and no one knows the full list.
  • Failure logs nobody reads: An exit code of 1 lands in a log file and reaches no one.
  • Dependencies that exist only on paper: The rule "run settlement after order aggregation finishes" lives in a handover document, not in code.
  • Scheduling and Dependency Management

    The most common incident comes from using clock time to enforce order. Schedule order aggregation at 01:00 and settlement at 02:00, and everything works while aggregation finishes in its usual 40 minutes. On the day data growth pushes it to 70 minutes, settlement runs against half-aggregated data. It finishes as a "success" with no error, which makes it more dangerous.

  • Time-based execution: Use it only when the time itself is the condition, such as an external cutoff.
  • Completion-based execution: Start the downstream job only when the upstream job has finished successfully.
  • A central scheduler is worth considering once you have more than 20 jobs, dependency chains three or more levels deep, or jobs running on two or more servers. Before that, build the job inventory. Putting job name, run time, upstream jobs, typical duration, and owner in a single table is often enough to expose missing jobs and jobs with no owner.

    Building Batches That Are Safe to Fail

    Design on the assumption that the batch will fail. The key question is whether it is safe to run again.

  • Idempotency: Running twice for the same date must give the same result. Replace plain INSERTs with an UPSERT keyed on settlement date and account, or delete that date's rows and reload them.
  • Checkpoint restart: Commit 30,000 records in chunks of 1,000 and record the position. If the job fails at record 18,000, it resumes from record 18,001.
  • Locks against duplicate runs: Use a lock so the next run cannot start while the previous one is still going. Give the lock an expiry so it does not linger forever when a process dies.
  • Partial failure handling: Don't let one bad record stop everything. Quarantine failed records in a separate table and abort the whole run only when the failure rate passes a threshold, for example 1%.
  • Monitoring and Alerting

    Failure alerts are not enough. If the server was off or the cron entry was deleted, there is no failure to report. Four things need detecting.

  • Failure: Deliver the exit code and error message immediately.
  • Did not run: If a job due at 02:00 has sent no start signal by 02:15, alert.
  • Running longer than usual: Warn when a job that normally takes 40 minutes passes 60 minutes, 1.5 times its norm.
  • Abnormal record counts: Check any run that deviates more than ±30% from the 7-day average of 30,000 records, meaning under 21,000 or over 39,000. "Succeeded but processed zero records" is the most common silent failure.
  • Alerts need a primary owner and a secondary who is paged after 30 minutes without a response. A message posted only to a channel everyone receives gets read by no one.

    Operations Handover

    The person who built a batch is rarely the person who runs it. Each job needs a reprocessing runbook that covers:

  • The rerun command and its arguments, such as the target date
  • When a rerun is safe and when it is not
  • The impact of a failure: which screens, which reports, and which downstream jobs are affected
  • The deadline for recovery before the business cutoff
  • Plan for a growing batch window as well. With data growing 30% a year, a 40-minute job takes about 68 minutes two years later. Splitting it into four partitions by account or date range and running them in parallel brings it down to roughly 17 minutes in theory. In practice database load makes it slower, so tune the degree of concurrency by measurement.

    How POLYGLOTSOFT Helps

    Batch operations are not something you build once. They need attention every time data and business rules change. Within a maintenance (SM) contract, POLYGLOTSOFT continuously improves your batch estate: organizing the job inventory, redesigning jobs for idempotency and restart, setting up monitoring for missed runs, delays, and abnormal counts, and writing reprocessing runbooks. If checking the settlement results is the first thing you do every morning, get in touch with POLYGLOTSOFT.

    Need Technical Consultation?

    Our expert consultants in smart factory, AI, and logistics automation will analyze your requirements.

    Request Free Consultation