-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Description
Summary
When creating a cron job with a time that has already passed today, the nextRunAtMs is incorrectly calculated as a date one year in the past (2025 instead of 2026), causing the job to never run.
This is a different bug from #10025 (which deals with off-by-one-day after execution). This issue occurs on initial job creation.
Environment
- OpenClaw version: 2026.2.1 (8650)
- Node.js: v25.5.0
- OS: macOS Darwin 24.6.0 (arm64)
- System time: 2026-02-06 08:20 (confirmed correct via
dateandDate.now())
Steps to Reproduce
-
At 08:20 (after 07:30), create a cron job scheduled for 07:30 daily:
openclaw cron add --name "Test" --cron "30 7 * * *" --tz "Asia/Shanghai" --message "test"
-
Check the job's
nextRunAtMs:openclaw cron list | grep nextRunAtMs -
Observe that
nextRunAtMsis1770420600000(2025-02-06 07:30 UTC) instead of1773960600000(2026-02-07 07:30 UTC).
Expected Behavior
For a job scheduled at 07:30, if current time is 08:20, nextRunAtMs should be tomorrow (2026-02-07 07:30).
Actual Behavior
nextRunAtMs is set to one year ago (2025-02-06 07:30), so the job never triggers.
Root Cause Analysis
The cron scheduler appears to incorrectly handle "past time" calculations. When the scheduled time has already passed for today, it should increment to the next day, but instead it decrements by approximately 365 days (one year).
Verified timestamps
- Incorrect:
1770420600000= 2025-02-06 07:30 UTC - Expected:
1773960600000= 2026-02-07 07:30 UTC - Gap: ~365 days (one full year)
Workaround
Manually edit ~/.openclaw/cron/jobs.json to fix nextRunAtMs after stopping Gateway:
pkill -f openclaw-gateway
sed -i '' 's/1770420600000/1773960600000/g' ~/.openclaw/cron/jobs.json
openclaw gateway startRelated Issues
- [Bug]: Cron scheduler off-by-one-day bug after job execution (updatedAtMs trigger) #10025 - Cron scheduler off-by-one-day bug after job execution (different issue: that one is about skipping a day after execution, this one is about wrong year on creation)
- [Bug] Cron jobs run at wrong time without explicit timezone #8399 - Cron jobs run at wrong time without explicit timezone
Impact
Any daily cron job created after its scheduled time will never run, causing:
- Missed daily reports/briefings
- Missed scheduled tasks
- Silent failures (no error logs, job just does not fire)