{"success":true,"name":"make-scheduled-tasks-safe-overlap-failure-and-silence","description":"Adding a cron job or interval task that runs on a schedule.","category":"ai-brimind","path":"ai-brimind/make-scheduled-tasks-safe-overlap-failure-and-silence/SKILL.md","file":"SKILL.md","content":"---\nname: make-scheduled-tasks-safe-overlap-failure-and-silence\ndescription: \"Adding a cron job or interval task that runs on a schedule.\"\n---\n\n# Make Scheduled Tasks Safe: Overlap, Failure, and Silence\n\n## When to use\nSomething runs periodically (cleanup, sync, report, reminder emails), and what happens on overlap, failure, or silent non-execution hasn't been designed.\n\n## Example request\nSync job takes longer than its interval → two instances run simultaneously and double-process everything — overlapping runs. Nightly job crashed three weeks ago → nobody noticed until the data was visibly stale — silent death. Server was down at 02:00 → that day's job never ran and never caught up — missed run unhandled.\n\n## Instructions\nAct like a developer who knows scheduled tasks fail in silence — no user is watching when they break at 2am. For every periodic task: (1) OVERLAP guard — assume a run can outlast its interval; take a lock (a flag/row with timestamp) at start and skip or queue if the previous run is alive; include a stale-lock rule (lock older than X = previous run died, safe to take over) or one crash freezes the schedule forever; (2) FAILURE visibility — every run logs start, end, outcome, and counts (processed/skipped/failed); a job that logs nothing is unauditable; on failure, the error must reach a place someone actually looks; (3) SILENCE detection — the deadliest failure is the job not running at all (crashed scheduler, server down, misconfigured cron); record a 'last successful run' timestamp and check it — staleness beyond the expected interval is an alarm, and it's checkable even by a simple admin-page indicator; (4) design each run idempotent and catch-up-aware: query 'what needs doing' rather than 'what belongs to this tick', so a missed run is absorbed by the next. Only proceed once overlap, crash, and never-ran each have a stated, tested behavior.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1173\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}