`every` 定时任务防漂移落地手册(PR #14832)
解决“每次任务执行后都往后漂移几秒,累计后严重错点”的场景:把 nextRun 计算锚定到 lastRun 而非 endedAt。
GITHUBDiscovered 2026-02-13Author shtse8
Prerequisites
- OpenClaw version includes PR #14832 or equivalent scheduler fix.
- You have recurring jobs with `schedule.kind = every` and can inspect run history.
Steps
- List all `every` jobs and record configured intervals versus observed trigger timestamps.
- Upgrade to PR #14832 build and restart gateway during a low-risk window.
- Run a controlled test: create a 60s `every` job with 5-10s execution duration and sample 10+ runs.
- Verify scheduler snaps forward from `lastRunAt + everyMs` and does not accumulate end-time drift.
- Keep alerting on abnormal drift as a regression guard.
Commands
openclaw gateway statusopenclaw gateway restartopenclaw cron listopenclaw cron runs --job <jobId>Verify
After 10+ cycles, trigger points remain aligned to expected interval boundaries, without +execution-time drift.
Caveats
- This fix targets `every` schedules; cron expression jobs use a different next-run path(需验证).
- Long runtime beyond multiple intervals still causes snap-forward skips by design.
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗