定时任务自检:避免 schedule.kind=cron 只推进 nextRunAt 不执行
解决‘cron 看起来在跑、实际不执行’的隐性故障。前置:使用 OpenClaw cron jobs 且能查看 runs 历史。步骤:先创建最小 cron 样例→强制 run 验证→对比 due 模式结果→上线前加入自检告警。关键命令:openclaw cron status/list/run/runs。验证:runs 有真实执行记录而不是仅 nextRunAt 前移。风险:生产任务若缺自检会长期静默失效。
GITHUBDiscovered 2026-02-14Author @spencerparkin
Prerequisites
- Cron scheduler is enabled and job definitions are managed via OpenClaw cron APIs/CLI.
- You can inspect job run history before/after changes.
Steps
- Create a minimal recurring cron job with a clear observable output (e.g., systemEvent text).
- Trigger a manual runMode=force execution and confirm the output path is healthy.
- Wait one scheduled interval and compare runs history against nextRunAt movement.
- If only timestamps move without runs, pin workaround: convert critical jobs to every until fix lands(需验证).
- Add a daily watchdog job that alerts when expected run count is below threshold.
Commands
openclaw cron statusopenclaw cron listopenclaw cron run --job-id <jobId>openclaw cron runs --job-id <jobId>Verify
A healthy cron job shows both advancing nextRunAt and new run history records with success/failure outcomes.
Caveats
- Do not assume scheduler health from timestamps alone.
- Issue behavior may change after patch release; re-test after upgrade(需验证).
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗