-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Closed
Closed
Copy link
Description
Summary
Cron scheduler miscalculates nextRunAtMs after job execution, skipping next day's scheduled run and jumping to day after (off-by-one day bug).
Steps to reproduce
- Create a daily cron job with schedule
"0 9 * * *"(9:00 AM daily) - Let the job execute on Day 1 (2026-02-05 09:00 AM)
- Check the job's
nextRunAtMsin~/.openclaw/cron/jobs.json
Expected behavior
After the job executes on Day 1 (2026-02-05 09:00 AM):
nextRunAtMsshould be set to Day 2 (2026-02-06 09:00 AM)- Job should fire on Day 2 at 09:00 AM
Actual behavior
After the job executes on Day 1 (2026-02-05 09:00 AM):
nextRunAtMsis incorrectly set to Day 3 (2026-02-07 09:00 AM)- Job does NOT fire on Day 2 (2026-02-06 09:00 AM)
- Gap between
lastRunAtMsandnextRunAtMsis ~48 hours instead of ~24 hours
Timeline
- 2026-02-05 09:00 AM: Job fires successfully
- Gateway updates
updatedAtMsto 1770253200008 (2026-02-05 09:00:00.008) - Scheduler miscalculates
nextRunAtMsas 1770426000000 (2026-02-07 09:00:00) - 2026-02-06 09:00 AM: Job does NOT fire (skipped)
⚠️ - 2026-02-07 09:00 AM: Next scheduled run (48 hours later)
Observed state (jobs.json)
{
"schedule": {
"kind": "cron",
"expr": "0 9 * * *",
"tz": "Asia/Shanghai"
},
"state": {
"lastRunAtMs": 1770253200009, // 2026-02-05 09:00:00.009
"nextRunAtMs": 1770426000000, // 2026-02-07 09:00:00.000 ← WRONG!
"lastStatus": "ok"
}
}Verified timestamps
# Expected next run:
2026-02-06 09:00:00 CST = 1770339600000 ms
# Actual next run:
2026-02-07 09:00:00 CST = 1770426000000 ms
# Gap: 86400000 ms = 24 hours (one full day skipped)Environment
- OpenClaw version: 2026.2.3-1
- OS: macOS 25.2.0 (arm64)
- Node: v25.6.0
- Gateway: Running (pid 6838), no restart on Day 1
Impact
Any daily cron job can skip an entire day's execution after a single successful run. This causes:
- Missed daily reports/briefings
- Missed scheduled backups
- Missed monitoring/alerts
- Silent failures (no error logs, job just does not fire)
Related issues
- Cron scheduler skips jobs after mid-day gateway restart #10021 - Cron scheduler skips jobs after mid-day gateway restart (similar root cause)
- Cron schedule update skips next scheduled run (off-by-one day) #4586 - Cron schedule update skips next scheduled run (off-by-one day) (same symptoms)
Additional context
- Gateway did NOT restart between Day 1 and Day 2 (verified via logs)
- The
updatedAtMsfield was updated by Gateway after job execution (1770253200008) - This update may trigger the same scheduling bug as described in Cron scheduler skips jobs after mid-day gateway restart #10021 and Cron schedule update skips next scheduled run (off-by-one day) #4586
- No cron execution logs for Day 2 at 09:00 AM
- Manual run attempt failed with "not-due" error (scheduler thinks next run is Day 3)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels