openclaw cron

管理 Gateway 调度器的定时任务。

相关文档:

提示:运行 openclaw cron --help 查看完整的命令列表。

注意:独立的 cron add 任务默认使用 --announce 投递模式。用 --no-deliver 可以让输出保留在内部。--deliver 作为已弃用的别名仍然有效。

注意:一次性(--at)任务在成功后默认自动删除。用 --keep-after-run 可以保留。

注意:重复执行的任务在连续出错后会使用指数退避重试(30s -> 1m -> 5m -> 15m -> 60m),下次成功后恢复正常调度。

注意:openclaw cron run 现在在手动运行入队后就返回。成功响应包含 { ok: true, enqueued: true, runId };用 openclaw cron runs --id <job-id> 跟踪最终结果。

注意:保留/清理策略在配置中控制:

  • cron.sessionRetention(默认 24h)清理已完成的独立运行会话。
  • cron.runLog.maxBytes + cron.runLog.keepLines 清理 ~/.openclaw/cron/runs/<jobId>.jsonl

升级提示:如果你有当前投递/存储格式之前的老定时任务,运行 openclaw doctor --fix。Doctor 现在会规范化旧版 cron 字段(jobIdschedule.cron、顶层投递字段、payload 的 provider 投递别名),并在配置了 cron.webhook 时将简单的 notify: true webhook 兜底任务迁移为显式 webhook 投递。

常见编辑操作

更新投递设置(不改消息内容):

openclaw cron edit <job-id> --announce --channel telegram --to "123456789"

禁用独立任务的投递:

openclaw cron edit <job-id> --no-deliver

为独立任务启用轻量级引导上下文:

openclaw cron edit <job-id> --light-context

广播到指定频道:

openclaw cron edit <job-id> --announce --channel slack --to "channel:C1234567890"

创建带轻量级引导上下文的独立任务:

openclaw cron add \
  --name "Lightweight morning brief" \
  --cron "0 7 * * *" \
  --session isolated \
  --message "Summarize overnight updates." \
  --light-context \
  --no-deliver

--light-context 仅适用于独立的 Agent 轮次任务。对于 cron 运行,轻量模式会让引导上下文保持为空,而不是注入完整的工作区引导文件集。