🦞 Cron Inspection —— 给 Agent 定时任务做"CT 扫描"

"世界上有一种任务叫做定时任务,它在凌晨 3 点准时执行,从不出声。有一天它不干了,你只能凭运气找问题——直到 Cron Inspection 出现,你终于能对着它的源代码说一句:原来问题在这儿。"

什么是 Cron Inspection?

Cron Inspection(cron.get) 是 OpenClaw v2026.5.12 新增的定时任务诊断功能。它允许 Operator 通过 openclaw cron get 命令和 Agent 工具 cron.get,直接查看单个 cron job 的完整配置当前状态运行元数据,而不再需要翻遍整个配置文件凭眼力找差异。

以前排查定时任务问题靠什么?靠"把这个 cron 删了重新配"。现在你只需要 cron.get <id>,老婆再也不用担心你删错任务了。

为什么需要 Cron Inspection?

在妙趣AI 的运营体系中,每天有 21+ 个定时任务在运行:

当某个任务"突然不干活了",以前的做法是:

  1. 打开 openclaw.yaml 找到对应 cron 配置
  2. 确认 schedule 表达式写对了(5 位?6 位?周几开始?)
  3. 检查有没有被其他配置覆盖
  4. 重启 Gateway 看看能不能跑

Cron Inspection 直接把这一切压缩成了一行命令。

OpenClaw 实战:使用 Cron Inspection

查看所有 cron job

# 列出所有定时任务
openclaw cron list --format table

# 输出
ID                    SCHEDULE     STATUS    LAST_RUN              NEXT_RUN
seo-batch-generate    0 1 * * *    active    2026-05-18 01:00:03   2026-05-19 01:00:00
competitor-monitor    0 3 * * *    active    2026-05-18 03:00:01   2026-05-19 03:00:00
glossary-generate     0 4 * * *    active    2026-05-18 04:00:00   2026-05-19 04:00:00
rss-aggregate         10 6 * * *   active    2026-05-18 06:10:02   2026-05-19 06:10:00
daily-report          0 22 * * *   paused    2026-05-17 22:00:01   2026-05-18 22:00:00

查看单个 cron job 详情(新功能)

# 查看 cron job 的完整配置和状态
openclaw cron get seo-batch-generate

# 输出(v2026.5.12 新增)
=== Cron Job Detail ===

ID:           seo-batch-generate
Agent:        miaoquai
Schedule:     0 1 * * * (UTC)
Status:       active
Created:      2026-04-01 00:00:00 UTC
Last Run:     2026-05-18 01:00:03 UTC (success)
Next Run:     2026-05-19 01:00:00 UTC
Run Count:    48

Task:
  Description:  大规模 SEO 内容生成
  Action:       generate_seo_pages
  Args:
    count: 5-10
    topic: OpenClaw & Agent Skills

History (last 5 runs):
  2026-05-18 01:00:03 - success (48.2s)
  2026-05-17 01:00:01 - success (52.1s)
  2026-05-16 01:00:02 - success (47.8s)
  2026-05-15 01:00:00 - success (51.3s)
  2026-05-14 01:00:01 - success (49.6s)

  Total success: 48 | Total failure: 0
  Avg duration:  49.8s

通过 Agent 工具调用

# 在 Agent 对话中直接检查 cron
你:检查一下竞品监控 cron 的状态

Agent(调用 cron.get):
// 内部实际调用
const result = await tools.cron.get({ id: "competitor-monitor" })

// 返回结果
{
  id: "competitor-monitor",
  agent: "miaoquai",
  schedule: "0 3 * * *",
  status: "active",
  lastRun: { time: "2026-05-18T03:00:01Z", success: true, duration: 35.2 },
  nextRun: "2026-05-19T03:00:00Z",
  runCount: 48,
  description: "竞品监控分析",
  history: [ ... ]
}

Cron Inspection 的原理

OpenClaw 的 Cron 子系统将每个定时任务存储为结构化记录,包含:

cron.get 直接从 Gateway 的内存数据库读取这些结构化记录,无需解析 YAML 或查询日志。

妙趣小结

以前排查 cron 问题:打开十层嵌套的 YAML 文件,对着 21 个定时任务挨个看,眼睛花了还找不出错。

现在:openclaw cron get <id> —— 所有信息一目了然。如果每个运维工具都这么友好,运维同学的头发起码能多留 30%。

📅 更新于 2026-05-18 · 妙趣AI · 🦞