Cron Jobs and Scheduling
Make scheduled work boring: idempotent handlers, distributed locks, leader election, heartbeats, clock-skew debugging, and cleanup jobs that respect retention rules.
Path overview
定时任务的危险之处在于平时正常、出错时在半夜。本路径围绕幂等与时钟两大主题,配齐分布式锁、领导者选举与心跳监控,再实战数据保留清理与两个完整项目,把夜间告警变成可控工程。
Scheduled jobs fail at 3 a.m. by design. This path centers idempotency and clocks, adds distributed locks, leader election, heartbeats, retention cleanup, and two complete projects.
Use "Cron Expression Explainer" on a cron sample, then check "text to explanation" against your manual result.
Next step: Inject a Clock Instead of Calling Date.now
⏱ 0.25h
Run "Make time-dependent logic deterministic by injecting a clock and testing the exact boundary" from "Inject a Clock Instead of Calling Date.now" and confirm the documented result "Domain code accepts a Clock, and only the composition root passes systemClock.".
Prerequisites: Cron Expression Explainer
Next step: Monitor Cron Jobs with Dead-Man's-Switch Heartbeats
⏱ 0.5h
Apply "Monitor Cron Jobs with Dead-Man's-Switch Heartbeats" to a cron task, checking that "HTTP 201 with a JSON object containing name nightly-billing-export, schedule 0 2 * * *," appears after the "Add success-only heartbeat pings to a scheduled PostgreSQL backup and configure a" step.
Prerequisites: Inject a Clock Instead of Calling Date.now
Next step: Clean Up Expired Idempotency Keys
⏱ 0.5h
Execute "Clean Up Expired Idempotency Keys" end to end, then repeat the last step with one parameter changed and compare "Keep the idempotency table small and fast without deleting keys that a client may still".
Prerequisites: Monitor Cron Jobs with Dead-Man's-Switch Heartbeats
Next step: Implement a Data Retention Cleanup
⏱ 0.5h
Carry out "Implement a Data Retention Cleanup" on a cron project, pausing at the "Remove data that is no longer needed while proving that legal holds and required records are" step to verify "Every data class has a documented retention rule and an exception path.".
Next step: Build a Cron Job Dashboard with Schedules and Run History
⏱ 1.5h
Deliver the "Build a Cron Job Dashboard with Schedules and Run History" blueprint with "Job CRUD from the UI with cron expressions parsed and validated with a next-run preview" working and "A scheduler loop that fires due jobs and tolerates clock skew and missed intervals" recorded as evidence.
Prerequisites: Implement a Data Retention Cleanup
Next step: Count Cron Runs Inside a Window
⏱ 7h
In the "Cron Jobs and Scheduling" path, implement "Count Cron Runs Inside a Window" so JSON object: { cron: */N * * * * | M * * * *, from: ISO string, to: yields {count:4,firstRuns:[2026-01-01T00:00:00.000Z,2026-01-01T00:15:00.000Z,, including the second sample's edge case.
Prerequisites: Build a Cron Job Dashboard with Schedules and Run History
Next step: Build an Incremental Backup Tool with Snapshot Catalogs
⏱ 0.42h
Ship "Content-defined chunking with a rolling hash boundary keeps chunk boundaries stable under" from "Build an Incremental Backup Tool with Snapshot Catalogs", then prove it with the project's test suite and an acceptance note.
Prerequisites: Build a Cron Job Dashboard with Schedules and Run History, Count Cron Runs Inside a Window
Next step: Apply this path in a capstone project and review the related resources.
⏱ 8h