openclaw - 💡(How to fix) Fix [Bug]: Cron cron:run API 返回成功但任务不执行 [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#43608Fetched 2026-04-08 00:16:50
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×2closed ×1commented ×1locked ×1

手动调用 cron:run API 触发定时任务时,API 返回 {"ok": true, "enqueued": true},但任务实际上根本没有执行。没有生成运行记录,日志中也没有任何执行痕迹。

Root Cause

手动调用 cron:run API 触发定时任务时,API 返回 {"ok": true, "enqueued": true},但任务实际上根本没有执行。没有生成运行记录,日志中也没有任何执行痕迹。

RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

手动调用 cron:run API 触发定时任务时,API 返回 {"ok": true, "enqueued": true},但任务实际上根本没有执行。没有生成运行记录,日志中也没有任何执行痕迹。

Steps to reproduce

创建一个 cron 任务(sessionTarget: isolated) 调用 cron:run 手动触发 观察返回 enqueued: true,但没有实际执行

Expected behavior

Expected behavior *

Actual behavior

API 返回成功 没有生成运行记录文件 日志中没有 "job run" 相关记录 任务状态 stuck 在 runningAtMs(即使没有实际会话在运行)

OpenClaw version

OpenClaw 2026.3.8 (3caab92)

Operating system

OS: Linux 6.6.87.2-microsoft-standard-WSL2 (x64) Node: v22.22.1 Model: MiniMax-M2.5 Gateway: 127.0.0.1:18789

Install method

No response

Model

minimax2.5

Provider / routing chain

openclaw -> cloudflare-ai-gateway -> minimax

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To resolve the issue of cron tasks not executing despite receiving a successful API response, we need to focus on the task execution mechanism. The problem seems to stem from the task being enqueued but not actually running. Here are the steps to fix this:

  • Check the cron task configuration to ensure it's correctly set up to run in an isolated session.
  • Verify that the cron:run API is correctly triggering the task.
  • Implement a retry mechanism for the cron task to handle potential failures.
  • Update the task execution logic to properly handle the enqueued state and ensure the task is actually executed.

Example code snippet to implement a retry mechanism:

// Define the maximum number of retries
const MAX_RETRIES = 3;

// Define the retry delay in milliseconds
const RETRY_DELAY = 5000;

// Function to execute the cron task with retries
async function executeCronTask(task) {
  let retries = 0;
  while (retries < MAX_RETRIES) {
    try {
      // Attempt to execute the task
      const result = await cron.run(task);
      if (result.enqueued) {
        // If the task is enqueued, wait for the retry delay and try again
        await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));
        retries++;
      } else {
        // If the task is executed successfully, break out of the loop
        break;
      }
    } catch (error) {
      // If an error occurs, log it and increment the retry count
      console.error(`Error executing cron task: ${error}`);
      retries++;
    }
  }
  if (retries >= MAX_RETRIES) {
    // If all retries fail, log an error and exit
    console.error(`Failed to execute cron task after ${MAX_RETRIES} retries`);
  }
}

Verification

To verify that the fix worked, you can:

  • Check the task execution logs to ensure the task is being executed correctly.
  • Verify that the task is completing successfully and not getting stuck in the runningAtMs state.
  • Test the cron:run API with the updated retry mechanism to ensure it's working as expected.

Extra Tips

  • Make sure to monitor the task execution logs and adjust the retry mechanism as needed to prevent overwhelming the system with retries.
  • Consider implementing a more robust task execution mechanism, such as using a message queue or a job scheduler, to handle task execution and retries.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Expected behavior *

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING