> For the complete documentation index, see [llms.txt](https://docs.cherryai.com.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cherryai.com.cn/advanced-basic/automation/scheduled-heartbeat.md).

# 定时任务、心跳与运行记录

定时任务用于“在确定时间做一件事”，心跳用于“每隔一段时间检查是否有事要做”。二者都依赖可用的 Agent 和工作区。

<figure><img src="/files/cgGLTYkflrskhwhODA3F" alt="从触发条件到 Agent 执行、发送通知和查看运行记录的自动化流程图"><figcaption><p>先确认触发方式和通知目标，再让 Agent 创建；保存后立即测试一次。</p></figcaption></figure>

## 优先让 Agent 创建

在【工作】中直接说明计划通常更快：

```
为当前 Agent 创建一个工作日 09:00 的任务：读取工作目录中的昨日数据，生成运营日报；成功后发送到已连接的飞书频道。先把配置给我确认，不要立即启用。
```

Agent 可以调用【定时任务】工具创建和管理计划。需要精确查看、筛选或编辑所有任务时，使用【设置】→【定时任务】。

## 手动创建

{% stepper %}
{% step %}

### 1. 打开【设置】→【定时任务】→【新建】

填写任务名称，选择 Agent 和工作区。
{% endstep %}

{% step %}

### 2. 写清任务提示词

说明数据位置、产物、边界和成功条件。定时任务没有人在旁边追问，提示词应比普通对话更完整。
{% endstep %}

{% step %}

### 3. 选择执行计划

可以选择一次性、间隔、每天、工作日、每周或自定义 Cron。确认时区和下一次运行时间符合预期。
{% endstep %}

{% step %}

### 4. 选择通知频道并测试

需要外部通知时选择已经建立接收目标的频道。保存后先点击【运行】，在【运行历史】查看状态、耗时和结果。
{% endstep %}
{% endstepper %}

## 计划方式怎么选

| 需求        | 建议方式     | 例子               |
| --------- | -------- | ---------------- |
| 某个时间只执行一次 | 一次性      | 明天下午提醒提交材料       |
| 每隔固定分钟检查  | 间隔       | 每 30 分钟检查任务状态    |
| 固定每天或工作日  | 每天 / 工作日 | 日报、开工检查          |
| 固定星期      | 每周       | 每周五生成周报          |
| 复杂日历规则    | Cron     | 已熟悉 Cron 且需要组合条件 |

## 使用场景：工作日日报

| 配置    | 建议起点                | 为什么           | 注意事项          |
| ----- | ------------------- | ------------- | ------------- |
| Agent | 使用已经手动跑通日报的专用 Agent | 避免自动任务承担未验证流程 | 不临时更换模型和工具    |
| 工作区   | 只包含日报输入与输出目录        | 输入边界清楚，产物容易查找 | 不覆盖原始数据       |
| 计划    | 【工作日】并确认下一次运行时间     | 比手写 Cron 更直观  | 节假日是否执行需自行确认  |
| 通知    | 先发送到测试群或自己的会话       | 便于检查格式与重复发送   | 正式启用前至少手动运行一次 |

### 完成标准

手动运行成功；【运行历史】能打开对应会话；日报文件落在约定目录；测试频道只收到一条消息；下一次运行时间正确。

## 心跳

路径：【工作】→ Agent 菜单→【编辑】→【基础】→【心跳检测】。

当前 Agent 初始开启心跳，间隔为 30 分钟。没有持续检查需求时可以关闭；需要明确时间、通知和运行记录的任务仍应使用定时任务。

{% hint style="warning" %}
不要让多个心跳和定时任务重复执行同一工作。重复计划不仅浪费用量，还可能生成多份文件或重复发送消息。
{% endhint %}

<details>

<summary>任务运行了但频道没有收到消息怎么办？</summary>

先看【运行历史】确认 Agent 是否成功。如果任务成功，再检查频道接收目标；如果任务失败，点击【查看会话】检查模型、权限、工作区和工具错误。

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cherryai.com.cn/advanced-basic/automation/scheduled-heartbeat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
