知识引擎/Hermes 知识引擎/定时任务 (Cron Scheduler)

通过自然语言或 cron 表达式自动调度任务。Hermes 通过单个 cronjob 工具暴露 cron 管理,使用动作风格的命令操作,而不是独立的 schedule/list/remove 工具。 Cron 任务可以: - 调度一次性或重复性任务 - 暂停、恢复、编辑、触发和删除任务

定时任务 (Cron Scheduler)

> 📖 本文档翻译自 Hermes Agent 官方文档 > 最后更新:2026-04-16


通过自然语言或 cron 表达式自动调度任务。Hermes 通过单个 cronjob 工具暴露 cron 管理,使用动作风格的命令操作,而不是独立的 schedule/list/remove 工具。

Cron 的功能

Cron 任务可以:

  • 调度一次性或重复性任务
  • 暂停、恢复、编辑、触发和删除任务
  • 为任务附加零个、一个或多个技能
  • 将结果投递回原始聊天、本地文件或配置的平台目标
  • 在新的 Agent 会话中使用正常的静态工具列表运行

:::warning

:::

创建定时任务

在聊天中使用 /cron

/cron add 30m "Remind me to check the build"
/cron add "every 2h" "Check server status"
/cron add "every 1h" "Summarize new feed items" --skill blogwatcher
/cron add "every 1h" "Use both skills and combine the result" --skill blogwatcher --skill find-nearby

通过独立 CLI

hermes cron create "every 2h" "Check server status"
hermes cron create "every 1h" "Summarize new feed items" --skill blogwatcher
hermes cron create "every 1h" "Use both skills and combine the result" \
  --skill blogwatcher \
  --skill find-nearby \
  --name "Skill combo"

通过自然对话

像平常一样请求 Hermes:

Every morning at 9am, check Hacker News for AI news and send me a summary on Telegram.

Hermes 会在内部使用统一的 cronjob 工具。

技能支持的 Cron 任务

Cron 任务可以在运行提示之前加载一个或多个技能。

单个技能

cronjob(
    action="create",
    skill="blogwatcher",
    prompt="Check the configured feeds and summarize anything new.",
    schedule="0 9 * * *",
    name="Morning feeds",
)

多个技能

技能按顺序加载。提示成为在这些技能之上的任务指令。

cronjob(
    action="create",
    skills=["blogwatcher", "find-nearby"],
    prompt="Look for new local events and interesting nearby places, then combine them into one short brief.",
    schedule="every 6h",
    name="Local brief",
)

当你希望定时 Agent 继承可复用的工作流,而不必将完整的技能文本塞入 cron 提示时,这很有用。

编辑任务

你不需要删除并重新创建任务就可以更改它们。

聊天

/cron edit <job_id> --schedule "every 4h"
/cron edit <job_id> --prompt "Use the revised task"
/cron edit <job_id> --skill blogwatcher --skill find-nearby
/cron edit <job_id> --remove-skill blogwatcher
/cron edit <job_id> --clear-skills

独立 CLI

hermes cron edit <job_id> --schedule "every 4h"
hermes cron edit <job_id> --prompt "Use the revised task"
hermes cron edit <job_id> --skill blogwatcher --skill find-nearby
hermes cron edit <job_id> --add-skill find-nearby
hermes cron edit <job_id> --remove-skill blogwatcher
hermes cron edit <job_id> --clear-skills

注意:

  • 重复的 --skill 会替换任务附加的技能列表
  • --add-skill 追加到现有列表而不替换
  • --remove-skill 移除特定的附加技能
  • --clear-skills 移除所有附加技能

生命周期操作

Cron 任务现在拥有比单纯的创建/删除更完整的生命周期。

聊天

/cron list
/cron pause <job_id>
/cron resume <job_id>
/cron run <job_id>
/cron remove <job_id>

独立 CLI

hermes cron list
hermes cron pause <job_id>
hermes cron resume <job_id>
hermes cron run <job_id>
hermes cron remove <job_id>
hermes cron status
hermes cron tick

各操作说明:

  • pause — 保留任务但停止调度
  • resume — 重新启用任务并计算下一次运行时间
  • run — 在下一次调度器滴答时触发任务
  • remove — 完全删除任务

工作原理

Cron 执行由 Gateway 守护进程处理。 Gateway 每 60 秒滴答一次调度器,在隔离的 Agent 会话中运行所有到期任务。

hermes gateway install     # 安装为用户服务
sudo hermes gateway install --system   # Linux:服务器启动时的系统服务
hermes gateway             # 或在前台运行

hermes cron list
hermes cron status

Gateway 调度器行为

每次滴答时 Hermes 会:

  1. ~/.hermes/cron/jobs.json 加载任务
  2. 检查 next_run_at 是否小于等于当前时间
  3. 为每个到期任务启动一个全新的 AIAgent 会话
  4. 可选地将一个或多个附加技能注入到该新会话中
  5. 运行提示至完成
  6. 投递最终响应
  7. 更新运行元数据和下一次调度时间

~/.hermes/cron/.tick.lock 处的文件锁防止重叠的调度器滴答重复运行同一批任务。

投递选项

调度任务时,你可以指定输出去向:

选项描述示例
"origin"回到任务创建的位置消息平台上的默认值
"local"仅保存到本地文件(~/.hermes/cron/output/)CLI 上的默认值
"telegram"Telegram 主频道使用 TELEGRAM_HOME_CHANNEL
"telegram:123456"按 ID 指定的 Telegram 聊天直接投递
"telegram:-100123:17585"特定 Telegram 话题chat_id:thread_id 格式
"discord"Discord 主频道使用 DISCORD_HOME_CHANNEL
"discord:#engineering"特定 Discord 频道按频道名称
"slack"Slack 主频道
"whatsapp"WhatsApp 主页
"signal"Signal
"matrix"Matrix 主房间
"mattermost"Mattermost 主频道
"email"电子邮件
"sms"通过 Twilio 的 SMS
"homeassistant"Home Assistant
"dingtalk"钉钉
"feishu"飞书/Lark
"wecom"企业微信
"weixin"微信
"bluebubbles"BlueBubbles(iMessage)
"qqbot"QQ Bot(腾讯 QQ)

Agent 的最终响应会自动投递。你不需要在 cron 提示中调用 send_message

响应包装

默认情况下,投递的 cron 输出会包装一个页眉和页脚,让接收者知道它来自定时任务:

Cronjob Response: Morning feeds
-------------

<agent output here>

Note: The agent cannot see this message, and therefore cannot respond to it.

要投递不带包装的原始 Agent 输出,将 cron.wrap_response 设置为 false

# ~/.hermes/config.yaml
cron:
  wrap_response: false

静默抑制

如果 Agent 的最终响应以 [SILENT] 开头,投递将被完全抑制。输出仍会保存在本地用于审计(在 ~/.hermes/cron/output/ 中),但不会向投递目标发送任何消息。

这对于只应在出现问题时报告的监控任务很有用:

Check if nginx is running. If everything is healthy, respond with only [SILENT].
Otherwise, report the issue.

失败的任务无论是否有 [SILENT] 标记都会投递——只有成功的运行可以被静默。

脚本超时

预运行脚本(通过 script 参数附加)的默认超时为 120 秒。如果你的脚本需要更长时间——例如包含随机延迟以避免机器人般的定时模式——可以增加此值:

# ~/.hermes/config.yaml
cron:
  script_timeout_seconds: 300   # 5 分钟

或设置 HERMES_CRON_SCRIPT_TIMEOUT 环境变量。解析顺序为:环境变量 → config.yaml → 120 秒默认值。

Provider 恢复

Cron 任务继承你配置的回退 Provider 和凭据池轮换。如果主 API Key 被限速或 Provider 返回错误,cron Agent 可以:

  • 回退到备用 Provider——如果你在 config.yaml 中配置了 fallback_providers(或旧版的 fallback_model
  • 轮换到同一 Provider 的下一个凭据——在你的凭据池

这意味着高频率或在高峰时段运行的 cron 任务更有弹性——单个被限速的 Key 不会导致整个运行失败。

调度格式

Agent 的最终响应会自动投递——你不需要在 cron 提示中为同一目标包含 send_message。如果 cron 运行调用 send_message 到调度器已经投递的完全相同的目标,Hermes 会跳过该重复发送并告诉模型将面向用户的内容放在最终响应中。仅对额外或不同的目标使用 send_message

相对延迟(一次性)

30m     → 在 30 分钟后运行一次
2h      → 在 2 小时后运行一次
1d      → 在 1 天后运行一次

间隔(重复)

every 30m    → 每 30 分钟
every 2h     → 每 2 小时
every 1d     → 每天

Cron 表达式

0 9 * * *       → 每天上午 9:00
0 9 * * 1-5     → 工作日上午 9:00
0 */6 * * *     → 每 6 小时
30 8 1 * *      → 每月 1 日上午 8:30
0 0 * * 0       → 每周日凌晨

ISO 时间戳

2026-03-15T09:00:00    → 2026 年 3 月 15 日上午 9:00 一次性运行

重复行为

调度类型默认重复行为
一次性(30m、时间戳)1运行一次
间隔(every 2h)forever运行直到被删除
Cron 表达式forever运行直到被删除

你可以覆盖它:

cronjob(
    action="create",
    prompt="...",
    schedule="every 2h",
    repeat=5,
)

编程式管理任务

面向 Agent 的 API 是一个工具:

cronjob(action="create", ...)
cronjob(action="list")
cronjob(action="update", job_id="...")
cronjob(action="pause", job_id="...")
cronjob(action="resume", job_id="...")
cronjob(action="run", job_id="...")
cronjob(action="remove", job_id="...")

对于 update,传入 skills=[] 来移除所有附加技能。

任务存储

任务存储在 ~/.hermes/cron/jobs.json 中。任务运行的输出保存在 ~/.hermes/cron/output/&#123;job_id&#125;/&#123;timestamp&#125;.md

存储使用原子文件写入,因此中断的写入不会留下部分写入的任务文件。

自包含的提示仍然重要

:::warning

:::

糟糕: "Check on that server issue"

好: "SSH into server 192.168.1.100 as user 'deploy', check if nginx is running with 'systemctl status nginx', and verify https://example.com returns HTTP 200."

安全

定时任务提示在创建和更新时会扫描提示注入和凭据泄露模式。包含不可见 Unicode 技巧、SSH 后门尝试或明显的秘密泄露负载的提示会被阻止。

Continue Exploring

继续探索

这不是课程式的上一篇下一篇,而是从当前节点向外继续漫游。

使用指南

配置 (Configuration)

All settings are stored in the /.hermes/ directory for easy access. :::tip ::: Settings are resolved in this order (highest priority first):

核心功能

工具与工具集 (Tools & Toolsets)

Tools are functions that extend the agent's capabilities. They're organized into logical toolsets that can be enabled or disabled per platform.

核心功能

记忆系统 (Memory System)

Hermes Agent has bounded, curated memory that persists across sessions. This lets it remember your preferences, your projects, your environment, and things it h

核心功能

技能系统 (Skill System)

技能是 Hermes 的可复用知识模块。每个技能都是一个 Markdown 文件,在激活时注入到 Agent 的上下文中——为其提供持久的工作流、领域知识和行为指南,而无需将这些内容塞入系统提示中。 技能是可热插拔的:你可以在会话中途安装、创建、编辑和切换技能。它们在 CLI、消息平台和 Gateway 后台任务中均可

核心功能

MCP 集成 (MCP Integration)

MCP 让 Hermes Agent 连接到外部工具服务器,使 Agent 能够使用 Hermes 本身之外的工具——GitHub、数据库、文件系统、浏览器栈、内部 API 等。 如果你曾想让 Hermes 使用一个已经存在于其他地方的工具,MCP 通常是最简洁的方式。 - 无需先编写原生 Hermes 工具即可访问外

核心功能

ACP 编辑器集成 (ACP Editor Integration)

Hermes Agent 可以作为 ACP 服务器运行,让 ACP 兼容的编辑器通过 stdio 与 Hermes 通信,并渲染: - 聊天消息 - 工具活动 - 文件差异 - 终端命令 - 审批提示 - 流式思考 / 响应片段 当你希望 Hermes 像编辑器原生的编程 Agent 一样工作,而不是独立的 CLI 或

Core Features

核心功能

Hermes 的能力核心:工具、记忆、技能、委派、自动化、语音、插件与浏览器控制。

31 篇文档30 个节点

当前节点

定时任务 (Cron Scheduler)

同主题继续探索

工具与工具集 (Tools & Toolsets)

Tools are functions that extend the agent's capabilities. They're organized into logical toolsets that can be enabled or disabled per platform.

记忆系统 (Memory System)

Hermes Agent has bounded, curated memory that persists across sessions. This lets it remember your preferences, your projects, your environment, and things it h

技能系统 (Skill System)

技能是 Hermes 的可复用知识模块。每个技能都是一个 Markdown 文件,在激活时注入到 Agent 的上下文中——为其提供持久的工作流、领域知识和行为指南,而无需将这些内容塞入系统提示中。 技能是可热插拔的:你可以在会话中途安装、创建、编辑和切换技能。它们在 CLI、消息平台和 Gateway 后台任务中均可

MCP 集成 (MCP Integration)

MCP 让 Hermes Agent 连接到外部工具服务器,使 Agent 能够使用 Hermes 本身之外的工具——GitHub、数据库、文件系统、浏览器栈、内部 API 等。 如果你曾想让 Hermes 使用一个已经存在于其他地方的工具,MCP 通常是最简洁的方式。 - 无需先编写原生 Hermes 工具即可访问外

ACP 编辑器集成 (ACP Editor Integration)

Hermes Agent 可以作为 ACP 服务器运行,让 ACP 兼容的编辑器通过 stdio 与 Hermes 通信,并渲染: - 聊天消息 - 工具活动 - 文件差异 - 终端命令 - 审批提示 - 流式思考 / 响应片段 当你希望 Hermes 像编辑器原生的编程 Agent 一样工作,而不是独立的 CLI 或

API 服务器 (API Server)

The API server exposes hermes-agent as an OpenAI-compatible HTTP endpoint. Any frontend that speaks the OpenAI format — Open WebUI, LobeChat, LibreChat, NextCha

相关节点

配置 (Configuration)

All settings are stored in the /.hermes/ directory for easy access. :::tip ::: Settings are resolved in this order (highest priority first):

工具与工具集 (Tools & Toolsets)

Tools are functions that extend the agent's capabilities. They're organized into logical toolsets that can be enabled or disabled per platform.

记忆系统 (Memory System)

Hermes Agent has bounded, curated memory that persists across sessions. This lets it remember your preferences, your projects, your environment, and things it h

技能系统 (Skill System)

技能是 Hermes 的可复用知识模块。每个技能都是一个 Markdown 文件,在激活时注入到 Agent 的上下文中——为其提供持久的工作流、领域知识和行为指南,而无需将这些内容塞入系统提示中。 技能是可热插拔的:你可以在会话中途安装、创建、编辑和切换技能。它们在 CLI、消息平台和 Gateway 后台任务中均可

MCP 集成 (MCP Integration)

MCP 让 Hermes Agent 连接到外部工具服务器,使 Agent 能够使用 Hermes 本身之外的工具——GitHub、数据库、文件系统、浏览器栈、内部 API 等。 如果你曾想让 Hermes 使用一个已经存在于其他地方的工具,MCP 通常是最简洁的方式。 - 无需先编写原生 Hermes 工具即可访问外

ACP 编辑器集成 (ACP Editor Integration)

Hermes Agent 可以作为 ACP 服务器运行,让 ACP 兼容的编辑器通过 stdio 与 Hermes 通信,并渲染: - 聊天消息 - 工具活动 - 文件差异 - 终端命令 - 审批提示 - 流式思考 / 响应片段 当你希望 Hermes 像编辑器原生的编程 Agent 一样工作,而不是独立的 CLI 或