Skip to content

[Bug]: Cron scheduler off-by-one-day bug after job execution (updatedAtMs trigger) #10025

@Guoyin-Wen

Description

@Guoyin-Wen

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

  1. Create a daily cron job with schedule "0 9 * * *" (9:00 AM daily)
  2. Let the job execute on Day 1 (2026-02-05 09:00 AM)
  3. Check the job's nextRunAtMs in ~/.openclaw/cron/jobs.json

Expected behavior

After the job executes on Day 1 (2026-02-05 09:00 AM):

  • nextRunAtMs should 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):

  • nextRunAtMs is 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 lastRunAtMs and nextRunAtMs is ~48 hours instead of ~24 hours

Timeline

  • 2026-02-05 09:00 AM: Job fires successfully
  • Gateway updates updatedAtMs to 1770253200008 (2026-02-05 09:00:00.008)
  • Scheduler miscalculates nextRunAtMs as 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

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions