Group
  • Deployment

    Schedule cron jobs in production without silent failures

    Run recurring jobs with locking, visibility, and alerts so a broken cron doesn't fail silently for weeks.

    • Improve quality
    • Automate workflows
    • Intermediate
    • General

Free Prompt

Set up cron jobs (recurring scheduled work) for production. I have periodic tasks like billing rollups, cleanup, digest emails, and expiring tokens; I need these to run reliably and complain when they don't. Cover each of these: 1. Where cron runs: use the platform's scheduler (Fly cron, Render cron, AWS EventBridge, GitHub Actions on a schedule, or a queue-backed scheduler like BullMQ). Do not use a single instance's local crontab; when that instance dies, the schedule vanishes. 2. Prevent double-runs: if the app runs on multiple instances, use a lock (a database row, a Redis lock, or the scheduler's built-in single-execution guarantee) so the same job doesn't run twice at once and double-charge or double-email users. 3. Idempotency: cron handlers must be safe to run twice. Redelivery and 'we ran it, but did it commit?' happen. Use idempotency keys or 'has this period already been processed' checks. 4. Timeouts and retries: bounded execution time (kill runaway jobs) and a retry policy for transient failures. Permanent failures alert me instead of silently retrying forever. 5. Observability: log every run's start, finish, and duration. Alert on: job didn't run when it was supposed to (missed schedule), job errored, job took much longer than usual. 'Silent success' is the failure mode: nothing looks broken because nothing is happening. 6. Timezones: pick UTC for the schedule expression and document the intent ('runs at 3am UTC = 10pm ET'). DST-based confusion around 'daily at 3am' is a real, recurring bug. Don't put critical business logic inside a cron handler without also having a manual trigger; when the scheduler is broken, you'll need to run it by hand. The deliverable is the scheduler configured, locking and idempotency in place for anything critical, missed-run and error alerts wired up, and a manual-trigger endpoint or CLI for each job I depend on.

What This Does / How This Helps

This runs scheduled jobs on a platform scheduler with locking, idempotency, timeouts, missed-run alerts, and a manual trigger for the ones you can't afford to skip. Cron is the category of bug where nothing looks wrong. The dashboard is green, no errors are logged, and three weeks later you notice nobody has received their weekly digest since the last deploy. Locking, missed-schedule alerts, and manual triggers turn cron from 'set it and hope' into a real, observable part of the app.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts