openclaw - 💡(How to fix) Fix [Feature]: Cron 定时任务应支持直接执行原始 shell 脚本,无需调用大模型 [1 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#54438Fetched 2026-04-08 01:27:31
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Code Example

{
  "payload": {
    "kind": "exec",
    "command": "bash /path/to/script.sh",
    "delivery": { "mode": "announce", "channel": "feishu", "to": "ou_xxx" }
  }
}

---

openclaw cron add --exec "bash ~/scripts/backup.sh" --announce --channel feishu --to "ou_xxx"
RAW_BUFFERClick to expand / collapse

Problem to solve

目前每次 cron 任务都会调用大模型——即使只是执行一个简单的 shell 脚本、调用一个 API 或发送一个 webhook。这很浪费、很慢,有时还会因为模型不可用或 token 限制而失败。很多自动化场景其实只需要执行一个确定性脚本,完全不需要 AI 推理。

Proposed solution

新增一种 cron payload 类型 exec,直接在 Gateway 主机上运行 shell 命令/脚本,可选择将输出投递到指定频道。API 示例:

{
  "payload": {
    "kind": "exec",
    "command": "bash /path/to/script.sh",
    "delivery": { "mode": "announce", "channel": "feishu", "to": "ou_xxx" }
  }
}

CLI 等价形式:

openclaw cron add --exec "bash ~/scripts/backup.sh" --announce --channel feishu --to "ou_xxx"

Evidence/examples

Linux crontab 可以每分钟执行 curl -s https://example.com/health >> /tmp/health.log,零额外开销;OpenClaw cron 即使对这种 trivial 任务也会强制触发一次 agent 调用。

Additional information

向后兼容:现有的 systemEventagentTurn payload 保持不变,exec 类型是纯增量添加。

extent analysis

Fix Plan

To implement the proposed solution, follow these steps:

  • Add a new exec payload type to the cron job configuration
  • Update the Gateway to run shell commands/scripts directly on the host
  • Implement output delivery to a specified channel

Example code snippet in Python:

import subprocess
import json

def execute_cron_payload(payload):
    if payload['kind'] == 'exec':
        command = payload['command']
        subprocess.run(command, shell=True)
        # Implement output delivery to a specified channel
        if 'delivery' in payload:
            delivery_mode = payload['delivery']['mode']
            if delivery_mode == 'announce':
                channel = payload['delivery']['channel']
                to = payload['delivery']['to']
                # Send output to the specified channel
                send_output_to_channel(channel, to)

def send_output_to_channel(channel, to):
    # Implement channel-specific output delivery
    if channel == 'feishu':
        # Use Feishu API to send output
        pass

Verification

To verify the fix, test the following scenarios:

  • Create a new cron job with the exec payload type
  • Run a simple shell script using the exec payload
  • Verify that the output is delivered to the specified channel

Extra Tips

  • Ensure that the Gateway has the necessary permissions to run shell commands/scripts on the host
  • Implement error handling and logging for the exec payload type
  • Consider adding support for additional delivery modes and channels in the future

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]: Cron 定时任务应支持直接执行原始 shell 脚本,无需调用大模型 [1 participants]