概述
hermes cron 管理内置的 cron 定时调度器。你可以创建定时任务,让 Hermes Agent 在指定时间执行操作、运行脚本,或将结果推送到消息平台。调度支持自然表达(如 30m、every 2h)和标准 cron 表达式(如 0 9 * * *)。
hermes cron <list|create|add|edit|pause|resume|run|remove|rm|delete|status|runs|history|tick>
子命令
list — 列出所有定时任务
hermes cron list
hermes cron list --all # 同时显示已暂停的任务
create / add — 创建定时任务
hermes cron create "0 9 * * 1-5" "总结昨天的会话并规划今天的任务"
hermes cron add "every 2h" --name "健康检查" --script ~/.hermes/scripts/health.py
常用选项:--name、--deliver、--repeat、--skill、--script、--no-agent、--workdir、--model、--provider。
--script指定~/.hermes/scripts/下的脚本。未加--no-agent时,脚本输出会被注入到 Agent 的 prompt;加了--no-agent后脚本本身就是任务,输出会被直接投递。--no-agent完全跳过 LLM,适合磁盘告警、CI 探测等守望脚本。
edit — 修改已有任务
hermes cron edit <job_id> --schedule "0 8 * * *" --prompt "新的提示词"
可选:--schedule、--prompt、--name、--deliver、--repeat、--skill、--add-skill、--remove-skill、--clear-skills、--script、--no-agent、--agent、--workdir、--model、--provider。
pause / resume — 暂停与恢复
hermes cron pause <job_id>
hermes cron resume <job_id>
run — 在下次 tick 时立即触发任务
hermes cron run <job_id>
可配合 --accept-hooks 自动批准任务中的 shell hook。
remove / rm / delete — 删除任务
hermes cron remove <job_id>
hermes cron rm <job_id>
hermes cron delete <job_id>
status — 检查调度器是否正在运行
hermes cron status
runs / history — 查看执行历史
hermes cron runs
hermes cron runs <job_id> --limit 20
tick — 立即执行一次到期任务并退出
hermes cron tick
hermes cron tick --accept-hooks
常见场景
每日早间汇总
hermes cron create "0 9 * * 1-5" "总结昨天的会话并规划今天的任务" --name morning-briefing
基于脚本的健康检查
hermes cron add "*/30 * * * *" --name health-check --script ~/.hermes/scripts/health.sh --no-agent --deliver telegram:123456
测试与迭代
hermes cron create "* * * * *" "快速测试" --name test-job
hermes cron run test-job-id
hermes cron edit test-job-id --schedule "0 9 * * *"
技巧
create和add是同一命令的别名。tick只处理一次到期任务后退出,适合调试和外部定时器调用。- 使用
--deliver投递到消息平台时,需要先运行网关。 - 可用
--model和--provider固定任务的推理模型。 --workdir会注入项目上下文文件(如AGENTS.md、CLAUDE.md、.cursorrules)并设置工作目录。