Skip to content

Cron scheduler skips next day after gateway restart #10698

@Lunar-actuary

Description

@Lunar-actuary

Bug Description

When the gateway restarts, the cron scheduler incorrectly recalculates nextRunAtMs for jobs that already ran earlier that day. Instead of scheduling the next run for tomorrow, it skips a day.

Steps to Reproduce

  1. Have a cron job scheduled for daily at 07:00 (e.g., 0 7 * * *)
  2. Let the job run successfully at 07:00 on Day 1
  3. Restart the gateway later on Day 1 (e.g., at 21:22)
  4. Observe that nextRunAtMs is now set to Day 3 instead of Day 2

Evidence

Event Timestamp nextRunAtMs
Job runs successfully Feb 6, 07:00 Set to Feb 7, 07:00 ✅
Gateway restarts Feb 6, 21:22
After restart Changed to Feb 8, 07:00 ❌

The run history shows:

  • runAtMs: 1770321600002 (Feb 6, 07:00 AEDT)
  • nextRunAtMs in run entry: 1770408000000 (Feb 7, 07:00 AEDT) ✅
  • nextRunAtMs in current job state: 1770494400000 (Feb 8, 07:00 AEDT) ❌

Expected Behavior

After gateway restart, the scheduler should preserve the correct nextRunAtMs or recalculate it correctly as the next occurrence of the cron expression (Feb 7, 07:00).

Actual Behavior

The scheduler skips a day and sets nextRunAtMs to Feb 8 instead of Feb 7.

Environment

  • OpenClaw version: 2026.2.3-1
  • OS: macOS 26.2 (arm64)
  • Node: v25.5.0
  • Cron expression: 0 7 * * *
  • Timezone: Australia/Melbourne

Workaround

Manual intervention required. Attempted cron action:update with patched state, but state appears to be read-only or immediately recalculated.

Additional Notes

This bug causes scheduled jobs to miss their expected runs, which is critical for daily automation tasks like morning briefings.

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