> 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/docs/zhong-wen-fan-ti/advanced-basic/automation/scheduled-heartbeat.md).

# 定時任務、心跳同運行記錄

定時任務用嚟「喺確定時間做一件事」，心跳用嚟「每隔一段時間檢查下有冇嘢要做」。兩者都依賴可用嘅 Agent 同工作區。

<figure><img src="/files/3a08227547d388822544cb016bd0e8390153e4ea" 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/docs/zhong-wen-fan-ti/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.
