OpenClawSkills
GitHub
自动化 • 5 分钟阅读

计划任务

网关调度程序的 Cron 作业 + 唤醒

注意

''Cron 与 Heartbeat?'' 请参阅 ''Cron 与 Heartbeat'' 了解何时使用它们的指南。

Cron 是网关的内置调度程序。它保留工作,唤醒代理

在正确的时间,并且可以选择将输出传递回聊天。

如果您想要_"每天早上运行这个"_或_"在 20 分钟内戳代理"_,

cron 是一种机制。

Tutorial.step

长篇大论;博士

- Cron <strong>在网关内部</strong>运行(而不是在模型内部)。

- 作业在 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'~/.openclaw/cron/'</code>' 下持续存在,因此重新启动不会丢失计划。

- 两种执行方式:

- <strong>主会话</strong>:将系统事件排入队列,然后在下一个心跳时运行。

- '<strong>'Isolated'</strong>': runs a dedicated agent turn in '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron:&lt;jobId&gt;'</code>', optionally delivering output.

- 唤醒是一流的:作业可以请求"立即唤醒"与"下一个心跳"。

Tutorial.step

快速入门(可操作)

创建一次性提醒,验证其存在并立即运行:

Bash
openclaw cron add   --name "Reminder"   --at "2026-02-01T16:00:00Z"   --session main   --system-event "Reminder: check the cron docs draft"   --wake now   --delete-after-run

openclaw cron list
openclaw cron run <job-id> --force
openclaw cron runs --id <job-id>

安排一个重复的隔离作业并进行交付:

Bash
openclaw cron add   --name "Morning brief"   --cron "0 7 * * *"   --tz "America/Los_Angeles"   --session isolated   --message "Summarize overnight updates."   --deliver   --channel slack   --to "channel:C1234567890"
Tutorial.step

工具调用等效项(网关 cron 工具)

有关规范的 JSON 形状和示例,请参阅'<a href="/automation/cron-jobs#json-schema-for-tool-calls" className="text-emerald-400 hover:text-emerald-300 transition-colors">'工具调用的 JSON 架构'</a>'。

Tutorial.step

cron 作业的存储位置

默认情况下,Cron 作业保留在位于 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'~/.openclaw/cron/jobs.json'</code>' 的网关主机上。

网关将文件加载到内存中并在更改时将其写回,因此需要手动编辑

仅当网关停止时才安全。更喜欢 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'openclaw cron add/edit'</code>' 或 cron

工具调用 API 进行更改。

Tutorial.step

初学者友好的概述

将 cron 作业视为:<strong>何时</strong>运行 + <strong>做什么</strong>。

1. <strong>选择时间表</strong>

- 一次性提醒 → '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'schedule.kind = &quot;at&quot;'</code>' (CLI: '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'--at'</code>')

- 重复作业 → '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'schedule.kind = &quot;every&quot;'</code>' 或 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'schedule.kind = &quot;cron&quot;'</code>'

- 如果您的 ISO 时间戳省略时区,则会被视为 <strong>UTC</strong>。

2. <strong>选择运行位置</strong>

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'sessionTarget: &quot;main&quot;'</code>' → 在下一个心跳期间以主上下文运行。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'sessionTarget: &quot;isolated&quot;'</code>' → runs a dedicated agent turn in '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron:&lt;jobId&gt;'</code>'.

3. <strong>选择有效负载</strong>

- 主会议 → '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'payload.kind = &quot;systemEvent&quot;'</code>'

- 隔离会话 → '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'payload.kind = &quot;agentTurn&quot;'</code>'

可选:'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'deleteAfterRun: true'</code>' 从存储中删除成功的一次性作业。

Tutorial.step

概念

#

Tutorial.step

工作

cron 作业是一个存储的记录:

- <strong>时间表</strong>(何时运行),

- <strong>有效负载</strong>(它应该做什么),

可选的<strong>交付</strong>(应发送输出的位置)。

- 可选的'<strong>'代理绑定'</strong>' ('<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'agentId'</code>'):在特定代理下运行作业;如果

丢失或未知,网关会回退到默认代理。

作业由稳定的 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'jobId'</code>' 标识(由 CLI/网关 API 使用)。

在代理工具调用中,'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'jobId'</code>' 是规范的;为了兼容性,接受旧版 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'id'</code>'。

通过 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'deleteAfterRun: true'</code>' 成功一次性运行后,作业可以选择自动删除。

#

Tutorial.step

时间表

Cron 支持三种计划类型:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'at'</code>':一次性时间戳(自纪元以来的毫秒数)。网关接受 ISO 8601 并强制为 UTC。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'every'</code>':固定间隔(毫秒)。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron'</code>':带有可选 IANA 时区的 5 字段 cron 表达式。

Cron 表达式使用 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'croner'</code>'。如果省略时区,则网关主机的

使用本地时区。

#

Tutorial.step

主要执行与独立执行

##

Tutorial.step

主会话作业(系统事件)

主要作业将系统事件排入队列,并可选择唤醒心跳运行器。

他们必须使用 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'payload.kind = &quot;systemEvent&quot;'</code>'。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'wakeMode: &quot;next-heartbeat&quot;'</code>'(默认):事件等待下一个计划的心跳。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'wakeMode: &quot;now&quot;'</code>':事件触发立即心跳运行。

当您想要正常的心跳提示+主会话上下文时,这是最合适的。

请参阅'<a href="/gateway/heartbeat" className="text-emerald-400 hover:text-emerald-300 transition-colors">'心跳'</a>'。

##

Tutorial.step

隔离作业(专用 cron 会话)

隔离作业在会话 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron:&lt;jobId&gt;'</code>' 中运行专用的代理轮次。

关键行为:

- Prompts are prefixed with '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'[cron:&lt;jobId&gt; &lt;job name&gt;]'</code>' for traceability.

- 每次运行都会启动一个<strong>新的会话 ID</strong>(没有先前的对话结转)。

- 摘要发布到主会话(前缀 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'Cron'</code>',可配置)。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'wakeMode: &quot;now&quot;'</code>' 在发布摘要后立即触发心跳。

- 如果 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'payload.deliver: true'</code>',则输出被传送到通道;否则它会留在内部。

使用独立的作业来处理嘈杂、频繁或不应该发送垃圾邮件的"后台杂务"

您的主要聊天记录。

#

Tutorial.step

有效负载形状(运行的内容)

支持两种有效负载类型:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'systemEvent'</code>':仅限主会话,通过心跳提示进行路由。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'agentTurn'</code>':仅隔离会话,运行专用代理轮次。

常见 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'agentTurn'</code>' 字段:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'message'</code>':必需的文本提示。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'model'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'thinking'</code>':可选覆盖(见下文)。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'timeoutSeconds'</code>':可选的超时覆盖。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'deliver'</code>':'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'true'</code>' 将输出发送到通道目标。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'channel'</code>':'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'last'</code>' 或特定频道。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>':特定于频道的目标(电话/聊天/频道 ID)。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'bestEffortDeliver'</code>':避免在交付失败时作业失败。

隔离选项(仅适用于 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'session=isolated'</code>'):

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'postToMainPrefix'</code>' (CLI: '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'--post-prefix'</code>'):main 中系统事件的前缀。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'postToMainMode'</code>':'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'summary'</code>'(默认)或 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'full'</code>'。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'postToMainMaxChars'</code>':'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'postToMainMode=full'</code>' 时的最大字符数(默认 8000)。

#

Tutorial.step

模型和思维覆盖

孤立的工作('<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'agentTurn'</code>')可以覆盖模型和思维水平:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'model'</code>':提供商/型号字符串(例如,'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'anthropic/claude-sonnet-4-20250514'</code>')或别名(例如,'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'opus'</code>')

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'thinking'</code>':思维水平('<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'off'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'minimal'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'low'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'medium'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'high'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'xhigh'</code>';仅限 GPT-5.2 + Codex 型号)

注意:您也可以在主会话作业上设置 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'model'</code>' ,但它会更改共享主会话

会话模型。我们建议仅对孤立的作业进行模型覆盖,以避免

意想不到的环境变化。

分辨率优先级:

1. 作业负载覆盖(最高)

2. 特定于钩子的默认值(例如 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'hooks.gmail.model'</code>')

3.代理配置默认

#

Tutorial.step

交付(渠道+目标)

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'channel'</code>': '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'whatsapp'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'telegram'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'discord'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'slack'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'mattermost'</code>' (插件) / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'signal'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'imessage'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'last'</code>'

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>':特定于渠道的收件人目标

如果省略 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'channel'</code>' 或 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>' ,cron 可以回退到主会话的"最后一条路线"

(代理回复的最后一个地方)。

交货须知:

- 如果设置了 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>',即使省略 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'deliver'</code>',cron 也会自动传送代理的最终输出。

- 当您希望在没有显式 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>' 的情况下进行最后路由传递时,请使用 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>'。

- 即使存在 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>',也使用 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>' 将输出保持在内部。

目标格式提醒:

- Slack/Discord/Mattermost (plugin) targets should use explicit prefixes (e.g., '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'channel:&lt;id&gt;'</code>', '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'user:&lt;id&gt;'</code>') to avoid ambiguity.

- 电报主题应使用 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">':topic:'</code>' 形式(见下文)。

##

Tutorial.step

Telegram 传递目标(主题/论坛主题)

Telegram 通过 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'message_thread_id'</code>' 支持论坛主题。对于 cron 交付,您可以编码

将主题/线程放入 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'to'</code>' 字段:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'-1001234567890'</code>'(仅限聊天 ID)

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'-1001234567890:topic:123'</code>' (首选:明确的主题标记)

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'-1001234567890:123'</code>' (简写:数字后缀)

也接受像 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'telegram:...'</code>' / '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'telegram:group:...'</code>' 这样的前缀目标:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'telegram:group:-1001234567890:topic:123'</code>'

Tutorial.step

工具调用的 JSON 模式

ReferenceAutomationCronJobsPage step 16: P1

ReferenceAutomationCronJobsPage step 16: P2

ReferenceAutomationCronJobsPage step 16: Content

Tutorial.step

示例

一次性提醒:

Json
{
  "name": "Reminder",
  "schedule": { "kind": "at", "atMs": 1738262400000 },
  "sessionTarget": "main",
  "wakeMode": "now",
  "payload": { "kind": "systemEvent", "text": "Reminder text" },
  "deleteAfterRun": true
}

重复性、独立的交付工作:

Json
{
  "name": "Morning brief",
  "schedule": { "kind": "cron", "expr": "0 7 * * *", "tz": "America/Los_Angeles" },
  "sessionTarget": "isolated",
  "wakeMode": "next-heartbeat",
  "payload": {
    "kind": "agentTurn",
    "message": "Summarize overnight updates.",
    "deliver": true,
    "channel": "slack",
    "to": "channel:C1234567890",
    "bestEffortDeliver": true
  },
  "isolation": { "postToMainPrefix": "Cron", "postToMainMode": "summary" }
}

注意事项:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'schedule.kind'</code>':'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'at'</code>' ('<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'atMs'</code>')、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'every'</code>' ('<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'everyMs'</code>') 或 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron'</code>'('<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'expr'</code>',可选 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'tz'</code>')。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'atMs'</code>' 和 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'everyMs'</code>' 是纪元毫秒。

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'sessionTarget'</code>' 必须是 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'&quot;main&quot;'</code>' 或 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'&quot;isolated&quot;'</code>' 并且必须匹配 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'payload.kind'</code>'。

- 可选字段:'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'agentId'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'description'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'enabled'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'deleteAfterRun'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'isolation'</code>'。

- 省略时 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'wakeMode'</code>' 默认为 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'&quot;next-heartbeat&quot;'</code>'。

#

Tutorial.step

cron.update 参数

Json
{
  "jobId": "job-123",
  "patch": {
    "enabled": false,
    "schedule": { "kind": "every", "everyMs": 3600000 }
  }
}

注意事项:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'jobId'</code>' 是规范的;出于兼容性考虑,接受 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'id'</code>'。

- 在补丁中使用'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'agentId: null'</code>'来清除代理绑定。

#

Tutorial.step

cron.run 和 cron.remove 参数

Json
{ "jobId": "job-123", "mode": "force" }
Json
{ "jobId": "job-123" }
Tutorial.step

存储和历史记录

- 作业存储:'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'~/.openclaw/cron/jobs.json'</code>'(网关管理的 JSON)。

- Run history: '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'~/.openclaw/cron/runs/&lt;jobId&gt;.jsonl'</code>' (JSONL, auto-trimmed).

- 覆盖配置中的存储路径:'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.store'</code>'。

Tutorial.step

配置

Json5
{
  cron: {
    enabled: true, // default true
    store: "~/.openclaw/cron/jobs.json",
    maxConcurrentRuns: 1, // default 1
  },
}

完全禁用 cron:

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.enabled: false'</code>'(配置)

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'OPENCLAW_SKIP_CRON=1'</code>'(环境)

Tutorial.step

CLI 快速入门

一键提醒(UTC ISO,成功后自动删除):

Bash
openclaw cron add   --name "Send reminder"   --at "2026-01-12T18:00:00Z"   --session main   --system-event "Reminder: submit expense report."   --wake now   --delete-after-run

一键提醒(主会话,立即唤醒):

Bash
openclaw cron add   --name "Calendar check"   --at "20m"   --session main   --system-event "Next heartbeat: check calendar."   --wake now

重复性隔离工作(发送至 WhatsApp):

Bash
openclaw cron add   --name "Morning status"   --cron "0 7 * * *"   --tz "America/Los_Angeles"   --session isolated   --message "Summarize inbox + calendar for today."   --deliver   --channel whatsapp   --to "+15551234567"

重复性隔离作业(发送到 Telegram 主题):

Bash
openclaw cron add   --name "Nightly summary (topic)"   --cron "0 22 * * *"   --tz "America/Los_Angeles"   --session isolated   --message "Summarize today; send to the nightly topic."   --deliver   --channel telegram   --to "-1001234567890:topic:123"

具有模型和思维覆盖的孤立工作:

Bash
openclaw cron add   --name "Deep analysis"   --cron "0 6 * * 1"   --tz "America/Los_Angeles"   --session isolated   --message "Weekly deep analysis of project progress."   --model "opus"   --thinking high   --deliver   --channel whatsapp   --to "+15551234567"

代理选择(多代理设置):

Bash
openclaw cron add --name "Ops sweep" --cron "0 6 * * *" --session isolated --message "Check ops queue" --agent ops


openclaw cron edit <jobId> --agent ops
openclaw cron edit <jobId> --clear-agent

手动运行(调试):

Bash
openclaw cron run <jobId> --force

编辑现有作业(修补字段):

Bash
openclaw cron edit <jobId>   --message "Updated prompt"   --model "opus"   --thinking low

运行历史:

Bash
openclaw cron runs --id <jobId> --limit 50

无需创建作业即可立即发生系统事件:

Bash
openclaw system event --mode now --text "Next heartbeat: check battery."
Tutorial.step

网关API接口

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.list'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.status'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.add'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.update'</code>'、'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.remove'</code>'

- '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.run'</code>'(强制或到期),'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.runs'</code>'

对于没有作业的即时系统事件,请使用 '<a href="/cli/system" className="text-emerald-400 hover:text-emerald-300 transition-colors">''<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'openclaw system event'</code>''</a>'。

Tutorial.step

故障排除

#

Tutorial.step

"没有任何运行"

- 检查 cron 是否已启用:'<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron.enabled'</code>' 和 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'OPENCLAW_SKIP_CRON'</code>'。

- 检查网关是否连续运行(cron 在网关进程内运行)。

- 对于 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'cron'</code>' 时间表:确认时区 ('<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'--tz'</code>') 与主机时区。

#

Tutorial.step

Telegram 发送到错误的地方

- For forum topics, use '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'-100…:topic:&lt;id&gt;'</code>' to be explicit and unambiguous.

- 如果您在日志或存储的"最后一条路线"目标中看到 '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'telegram:...'</code>' 前缀,这是正常的;

cron 交付接受它们并仍然正确解析主题 ID。