Skip to content

Cron jobs skip scheduled runs after gateway restart #10574

@petterahlen-commits

Description

@petterahlen-commits

Summary

Cron jobs scheduled to run BEFORE a gateway restart are not executed in catch-up mode. Instead, their nextRunAtMs is recalculated to the next occurrence, effectively skipping that day's run.

Steps to Reproduce

  1. Have cron jobs scheduled (e.g., daily at 15:00)
  2. Restart gateway at any time AFTER the scheduled time (e.g., 17:00)
  3. Observe that jobs scheduled for earlier that day (before restart) never run
  4. Check job state - nextRunAtMs jumps to next week/day

Expected Behavior

Jobs should either:

  • Run immediately on restart if their scheduled time has passed
  • Or at minimum, not skip to the next occurrence without any warning

Actual Behavior

Jobs silently skip their scheduled run. No warning in logs. The scheduler recalculates the next run time based on the new restart time, causing missed executions.

Environment

  • OpenClaw version: 2026.2.3-1
  • OS: macOS Darwin 24.6.0 (arm64)
  • Node: v22.22.0

Impact

Critical for users relying on daily automated tasks (notifications, monitoring, reminders, etc.). Missed runs can go unnoticed until users manually check.

Workaround

Manual heartbeat checks with tracker files to detect and resend missed jobs. But this is error-prone and adds complexity.

Suggested Fix

  1. On scheduler init, check if any job's last scheduled time was missed
  2. Either run missed jobs immediately, or log a warning
  3. Consider adding a catchUp: true option for jobs that should always run if missed

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