AI-Generated Cron Jobs: 13 Mistakes to Catch in Code Review
Scheduled-job code from a coding assistant can look right and still run at the wrong time, twice, or never. Thirteen patterns to check in review, each with the rule and the fix.
Blog · Page 5 of 6
Why scheduled jobs miss runs or fail silently, and how to catch it in the schedulers you already use.
Scheduled-job code from a coding assistant can look right and still run at the wrong time, twice, or never. Thirteen patterns to check in review, each with the rule and the fix.
Read-only commands that list scheduled work on Linux, Windows, macOS, Kubernetes, clouds, CI, frameworks, and databases, a fleet script that writes one CSV, and a diff against your monitors.
Cron mails job output or drops it. Send it to a file, journald, or stdout, give every run JSON start and end lines that share a run ID, rotate the logs, and link each run to its log search.
Whoever gets the alert should be able to fix the job without you. A runbook template for scheduled jobs, a filled-in nightly export, and a rerun script that takes the lock and checks in.
Zero rows imported, an empty export, an API that answered 200 with no data. Where silent success comes from, the in-job checks that catch it, and outcome checks that alert on the numbers.
Healthchecks, Uptime Kuma push monitors, Prometheus, and a homegrown checker compared: what you must run, how each decides a job is late, who watches the monitor, and when to buy instead.
Already on Sentry? How Sentry Crons check-ins, schedules, max runtime, alerts, and per-monitor pricing compare with a dedicated cron monitor, and which one fits your scheduled jobs.
Spring's six-field cron syntax, the single scheduler thread behind most late tasks, overlap under virtual threads and replicas, what Actuator shows, and check-ins that alert on missed runs.
msdb queries for job outcomes, failures, and long-running jobs; why Agent history disappears; Database Mail alerts; and HTTP check-ins that catch the runs Agent never reports.
No worker consuming scheduler_default means no runs. How RecurringMessage, #[AsCronTask], stateful(), and lock() behave across restarts and deploys, a not-running checklist, and check-ins.
A .timer unit starts a .service on a schedule. OnCalendar examples, interval timers, the options that move run times, failure hooks, and a checklist for timers that never fire.
Timers add catch-up runs, overlap protection, time limits, and journal logs; cron stays simpler and runs anywhere. A feature table, OnCalendar translations, and a migration that avoids double runs.
Preview next runs with a parser that reads the schedule the way your scheduler does, reproduce cron's user and environment, start a real run without waiting, and test the logic with a fixed clock.
Point a cron job at an Uptime Kuma push monitor: what status, msg, and ping do, how the Heartbeat Interval and retries decide down, why restarts delay checks, and how it compares to CronRadar.
Vercel calls your cron path with a GET on production only, in UTC, and never retries. Plan limits, Hobby's hour-wide timing, timeouts, and a Next.js route that reports every run.
Cron wakes every minute, runs each matching crontab line through the shell, and mails any output. Which cron each distro ships, what it leaves to you, and why its classic failure is silence.
Task Scheduler skips runs quietly and can report a failed script as 0x0. Decode Last Run Result, turn on history, query it with PowerShell, and get alerted when a task fails or never starts.
A practical cron expression reference: the five fields, operators, a table of common schedules, every-2-months jobs, and the mistakes that make cron run at the wrong time.
Eight checks that keep scheduled automation from failing quietly: exit codes, idempotency, overlap locks, timeouts, bounded retries, result checks, missed-run detection, and tested alerts.
A cron job that stops running produces no error. How a dead man's switch catches it with heartbeats, schedules, and grace periods, plus a wrapper that keeps the job's exit code.