用 Cron 自动化
Cron 是 Anyy 的 resident scheduler。适合 reminders、recurring agent turns、scheduled skill work、notification-style jobs,以及在 gateway runtime 里运行的 script jobs。
完整行为参考见 Cron。
Cron 在 resident gateway 内运行。创建或编辑 job 会写入本地 state,但只有 gateway scheduler 正在运行时,scheduled work 才会触发。
选择合适的 Job 形态
| 需求 | 使用 |
|---|---|
| 一次性提醒消息 | 在 chat 中提出,或创建 notify / reminder job。 |
| 周期性的 agent 工作 | anyy cron create --prompt ...,或让 Anyy 帮你调度。 |
| 可重复的 skill workflow | 添加 --kind skill --skills name1,name2。 |
| 不需要 LLM | 在 <home>/scripts 下创建 script job。 |
Scheduled prompt 不是你当前的前台聊天。把数据来源、指令、输出格式、投递要求和安静情况的行为写进 job 自己的 prompt。
创建提醒
从 chat:
Remind me in 30 minutes to check the build.
从 CLI:
anyy cron create \
--name "Check build" \
--schedule "30m" \
--kind notify \
--prompt "Check the build."
Model-created reminders 会存成带 reminder metadata 的 notification-style cron jobs。CLI 创建的 notify job 会把存储的 prompt 作为投递消息。
创建周期 Agent Job
使用简单 interval:
anyy cron create \
--name "Hourly inbox check" \
--schedule "every 1h" \
--prompt "Check what needs my attention and summarize it."
需要固定墙上时间的分钟或小时,用当前支持的 advanced cron 子集:
anyy cron create \
--name "Morning summary" \
--schedule "0 9 * * *" \
--prompt "Send my morning summary."
当前 parser 只接受五字段表达式中 day、month、weekday 都是 *,minute 和 hour 是 * 或单个数字。示例:
0 9 * * * # 每天 09:00
30 * * * * # 每小时第 30 分钟
* 14 * * * # 14 点这一小时内每分钟
Calendar-style recurrence 还不支持。Advanced cron 需要可靠的 IANA timezone。Anyy 无法解析可靠 timezone 时,会拒绝创建,而不是静默猜测。
运行 Script Job
当脚本已经能产生你要的输出、并且不需要模型推理时,用 script job。
把可执行脚本放在 profile 的 scripts/ 目录下:
mkdir -p ~/.anyy/scripts
$EDITOR ~/.anyy/scripts/check-build.sh
chmod +x ~/.anyy/scripts/check-build.sh
然后按文件名调度脚本:
anyy cron create \
--name "Build watchdog" \
--schedule "every 30m" \
--script check-build.sh \
--delivery-target current_user_default \
--delivery-channel telegram
Runtime 会在 <home>/scripts 内解析脚本,使用 subprocess environment 运行,并把 stdout/stderr 存为 cron result。解析到 scripts 目录外的 script path 会被拒绝。
投递到消息平台
投递到已配置 channel:
anyy cron create \
--name "Weixin digest" \
--schedule "0 9 * * *" \
--prompt "Send my morning digest." \
--delivery-target current_user_default \
--delivery-channel weixin
Channel 必须已经配置,并能通过 gateway 投递消息。current_user_default 还需要能解析到匹配的默认 channel binding。
其他 delivery target 包括 gateway、origin 和 none。none 可用于 CLI-created jobs,但 model-created automation tools 会拒绝它,因为它保留给 internal scheduler jobs。
查看历史
列出 jobs:
anyy cron list
anyy cron list --include-disabled
在对话里,也可以让 Anyy 列出 scheduled automations 或最近 automation history。Model-visible automation tools 支持用户可见 job kind 的创建、更新、删除、立即运行和历史查询。Script jobs 有意通过 CLI 创建,而不是由模型创建。
编辑或删除
暂停:
anyy cron update --id cron_123 --disable
恢复:
anyy cron update --id cron_123 --enable
修改 schedule 或 prompt:
anyy cron update \
--id cron_123 \
--schedule "every 2h" \
--prompt "Send a shorter summary."
删除:
anyy cron delete --id cron_123
如果 job 创建在不同的 runtime scope 下,使用 --role、--workspace 或 --all-scopes。
故障排查
| 现象 | 检查 |
|---|---|
| Job 没运行 | 确认 anyy gateway status 和 anyy doctor;cron 在 resident runtime 内运行。 |
| Cron 表达式被拒绝 | 使用 duration、every <duration>、RFC3339 timestamp,或支持的 minute/hour cron 子集。 |
| 没有 channel delivery | 确认 channel 已配置、channels doctor 通过,并且 delivery target 能解析。 |
| Job 列不出来 | 传 --include-disabled、--role、--workspace 或 --all-scopes。 |
| Script job 失败 | 确认脚本可执行、位于 <home>/scripts 下,并且不依赖缺失的 environment。 |