xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

OpenClaw 设置 cron 定时任务 All In One

OpenClaw 设置 cron 定时任务 All In One

feishu weather bot

errors

问题原因
shanghai-weather-daily 任务确实配置了,但连续失败了 3 次,错误信息:
Delivering to Feishu requires target <chatId|user:openId|chat:chatId>

问题根源
任务的 delivery.channel 设置为 "last",但在 Feishu 中需要一个明确的目标聊天 ID。当前配置无法解析到正确的接收目标

修复方案
需要修改 cron 任务配置,指定明确的 Feishu 聊天 ID。有两个选项:

image

cron (Gateway)

$ openclaw cron --help

🦞 OpenClaw 2026.3.23-2 (7ffe7e4) — I've read more man pages than any human should—so you don't have to.

Usage: openclaw cron [options] [command]

Manage cron jobs (via Gateway)

Options:
  -h, --help  Display help for command

Commands:
  add         Add a cron job
  disable     Disable a cron job
  edit        Edit a cron job (patch fields)
  enable      Enable a cron job
  help        Display help for command
  list        List cron jobs
  rm          Remove a cron job
  run         Run a cron job now (debug)
  runs        Show cron run history (JSONL-backed)
  status      Show cron scheduler status

Docs: docs.openclaw.ai/cli/cron
Upgrade tip: run `openclaw doctor --fix` to normalize legacy cron job storage.

$ openclaw cron run <job-id>
$ openclaw cron runs --id <job-id>

image

$ openclaw cron list
ID                                   Name                     Schedule                         Next       Last       Status    Target    Agent ID   Model               
4c382689-4059-442d-b942-d54aea6b6802 shanghai-weather-daily   cron 0 8 * * * @ Asia/Shangha... in 20h     8m ago     error     isolated  main  

image

# job id
$ openclaw cron run <job id>

# ✅ job id
$ openclaw cron run 4c382689-4059-442d-b942-d54aea6b6802
{
  "ok": true,
  "enqueued": true,
  "runId": "manual:4c382689-4059-442d-b942-d54aea6b6802:1774669108375:2"
}

image

# ❌ job name
$ openclaw cron run shanghai-weather-daily
GatewayClientRequestError: Error: unknown cron job id: shanghai-weather-daily

image

# 配置文件
$ cat /home/xgqfms/.openclaw/cron/jobs.json

image

demos

corn jobs

{
  "version": 1,
  "jobs": [
    {
      "id": "4c382689-4059-442d-b942-d54aea6b6802",
      "agentId": "main",
      "name": "shanghai-weather-daily",
      "enabled": true,
      "createdAtMs": 1774554499198,
      "updatedAtMs": 1774666923746,
      "schedule": {
        "kind": "cron",
        "expr": "0 8 * * *",
        "tz": "Asia/Shanghai"
      },
      "sessionTarget": "isolated",
      "wakeMode": "now",
      "payload": {
        "kind": "agentTurn",
        "message": "请获取上海今天的天气预报,并提醒我是否需要注意防晒和带雨伞。"
      },
      "delivery": {
        "mode": "announce",
        "channel": "chat:oc_c3991196c******acc76914eba"
      },
      "state": {
        "nextRunAtMs": 1774742400000,
        "lastRunAtMs": 1774666897002,
        "lastRunStatus": "error",
        "lastStatus": "error",
        "lastDurationMs": 26744,
        "lastDeliveryStatus": "unknown",
        "consecutiveErrors": 4,
        "lastError": "Delivering to Feishu requires target <chatId|user:openId|chat:chatId>"
      }
    }
  ]
}

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

jq errors

# pretty print JSON
$ cat /home/xgqfms/.openclaw/cron/jobs.json | jq .

# ✅ 像 cat 一样输出 JSON 内容
# . 表示“原样输出整个 JSON”
$ jq . /home/xgqfms/.openclaw/cron/jobs.json

# ❌ jq 错误用法
# $ jq /home/xgqfms/.openclaw/cron/jobs.json
# 等价于 JSON 的“pretty print”
$ jq '.' file.json
# 等价于
$ cat file.json | jq .

https://chatgpt.com/c/69c745fc-4fcc-832a-9de4-3f8e32c23754

refs

https://docs.openclaw.ai/cli/cron

https://docs.openclaw.ai/automation/cron-jobs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2026-03-28 11:19  xgqfrms  阅读(304)  评论(0)    收藏  举报