盘点并记录系统定时任务
扫描代码与配置中的调度任务,整理执行计划、依赖、失败影响、重跑方式和潜在运行风险。
完整提示词
<context>
Scheduled work is the part of a system people forget until it fails quietly: invoices not sent, a certificate not renewed, a cleanup that stopped months ago. Jobs are scattered across schedulers: crontab files, Kubernetes CronJobs, framework schedulers (Celery beat, Sidekiq-cron, Laravel's scheduler, Spring `@Scheduled`, node-cron), CI scheduled workflows, and cloud schedulers defined in Terraform. The details that matter are the ones that bite: the time zone the schedule is evaluated in (often UTC on the server, local in someone's head), what happens around daylight-saving changes, whether two runs can overlap (Kubernetes `concurrencyPolicy`, missing locks), whether a missed run is caught up or skipped, whether the job is safe to rerun, and whether anyone is alerted when it fails or simply does not run. Silent non-running is the most common failure and needs a heartbeat or dead-man check, not just error alerts.
</context>
<task>
Inventory and document the scheduled jobs in: {{scope}}
{{#notes}}Notes: {{notes}}{{/notes}}
1. Search for every scheduler: crontab files and cron syntax strings, Kubernetes CronJob manifests and Helm templates, framework scheduler registrations, CI scheduled triggers, cloud scheduler and event-rule resources in infrastructure code, and long-running workers with sleep loops or intervals.
2. For each job record: name, where it is defined, schedule in its original syntax and in plain words, the time zone it runs in (and how you know), what it does (from reading the code it calls), what it reads and writes, typical duration if visible, overlap protection, catch-up behaviour, idempotency, failure alerting and heartbeat, and owner if the code or CODEOWNERS shows one.
3. Note what breaks or who notices if the job fails or stops running.
4. Write rerun or manual-run instructions for each job from the code (the command, task name or console action), marked with a warning when a rerun is not safe.
5. Flag risks: no alerting, no overlap protection, non-idempotent jobs with retries, schedules in local time across daylight-saving changes, jobs that call code that no longer exists, and duplicated jobs in two schedulers.
</task>
<constraints>
- Do not trigger, run or disable any job; this is documentation from code and config.
- Say "unknown" for time zone, owner or alerting when the code does not show it; do not assume UTC without evidence.
- List jobs mentioned in notes but not found in code separately, as unverified.
{{> guardrails/investigate-before-answering}}
</constraints>
<output_format>
## Job inventory
Table: job, scheduler, schedule (plain words and time zone), purpose, alerting, owner.
## Job details
One subsection per job with the fields from step 2, failure impact and rerun steps.
## Risks found
Ranked list of risks with the job and evidence.
## Not found in code
Jobs that must be confirmed elsewhere (consoles, server crontabs) and how to check.
</output_format>可替换内容
- {{scope}}
- {{#notes}}
- {{notes}}
- {{/notes}}
- {{> guardrails/investigate-before-answering}}
分类与标签
编程开发、定时任务、作业调度、系统文档、运行风险