If you've ever debugged a cron job that failed on retry, you know the pain of "quietly improvising" automation—when a second run makes different decisions than the first, producing inconsistent results or duplicate actions.
The Problem with Stateless Cron Jobs
Traditional cron jobs are stateless by design. They fire, they do their thing, and if something goes wrong halfway through, the retry has no memory of what already happened. This leads to delightful surprises like sending notification emails twice, generating duplicate records, or picking a completely different "angle" on each attempt.
Enter the Run Manifest
A run manifest is a small file—typically JSON—that your cron job writes at the start of execution. It captures three critical pieces of information: what decision was made (which articles to publish, which users to email), why that decision was made (the state or inputs that drove it), and what actions are authorized (the scope of what's allowed). When your job runs again—whether by retry or manual trigger—it reads the manifest first. If a valid one exists, it skips the decision-making phase entirely.
Why This Pattern Works
The beauty here is simplicity. You're not building complex state machines or distributed locking systems. You're just creating an audit trail that says "we already figured this out; don't waste time re-deciding." The manifest becomes a contract between runs: this is what we decided, and the executor is only allowed to do these specific things.
Implementation Considerations
Store your manifest alongside your job's output or in a dedicated directory. Include timestamps, decision rationale, and explicit permission boundaries. When debugging, you can inspect the manifest to understand exactly why a particular run made its choices—no more guessing about what "really happened."
Key Takeaways
- Manifests make cron jobs idempotent without complex locking mechanisms
- A good manifest captures: decisions made, reasoning behind them, and action scope
- The pattern works for scheduled writers, batch processors, and notification systems alike
- Debugging becomes trivial when you have a permanent record of each run's state
The Bottom Line
This is the kind of small structural fix that pays massive dividends—manifests give your automation memory without adding complexity. If you're running any scheduled jobs in production, adopting this pattern today will save you from debugging headaches tomorrow.