修复 cron 随机窗口下 nextRunAt 前移导致的误跳过
用于“每小时触发 + 随机窗口判断是否执行”场景:升级到包含 PR #14068 的版本可避免 nextRunAt 变化时任务被错误跳过,适合社区增量抓取任务。
GITHUBDiscovered 2026-02-12Author WalterSumbon
Prerequisites
- You are running cron jobs that persist `lastRunAt/nextRunAt` in a state file.
- Gateway can be upgraded/restarted and cron logs are observable.
Steps
- Upgrade to a build that includes PR #14068, then restart gateway.
- Keep random-window logic in your scheduler: if now < nextRunAt then return `SKIP_NOT_DUE`.
- After each due run, atomically write both `lastRunAt` and a newly randomized `nextRunAt`.
- Run at least 20 trigger cycles and verify no false skip/duplicate run appears.
Commands
openclaw gateway statusopenclaw gateway restartopenclaw statusVerify
When current time passes `nextRunAt`, job executes exactly once; before due, it consistently returns `SKIP_NOT_DUE`.
Caveats
- This fix depends on runtime containing PR #14068; older builds may still skip incorrectly(需验证).
- State-file writes must be atomic; partial writes can still cause scheduling drift.
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗