> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/automate-protect-and-extend/zh/zi-dong-hua/task-engine.md).

# 任务引擎

该 **任务引擎** 可在 VergeOS 中启用自动化操作，可由特定事件触发或按计划时间触发。已定义的任务可根据您的配置执行一次或按周期重复运行。

## 基于事件的任务示例

当发生已定义的事件时，任务会自动触发：

* 当系统更新完成时发送电子邮件通知
* 当指定用户登录 VergeOS 时，启动某台特定虚拟机
* 当检测到同步错误时，使用 Webhook 通知外部告警系统

## 基于计划的任务示例

任务会在预定义的时间或间隔运行：

* 每周六下午 5:00 检查并下载系统更新
* 在创建 30 天后禁用用户账户（例如临时员工）
* 在特定日期关闭某个租户

## 任务引擎组件

| 组件          | 描述                         |
| ----------- | -------------------------- |
| **任务**      | 定义要执行的操作（例如，关闭虚拟机、发送通知）    |
| **计划**      | 指定任务应何时以及以多大频率运行（例如，每日、每周） |
| **事件**      | 定义触发任务的条件（例如，用户登录、同步失败）    |
| **Webhook** | 将数据实时推送到外部系统的特殊任务          |
| **任务日志**    | 记录任务创建和执行历史，用于审计和故障排查      |

## 模块化自动化架构

VergeOS 任务引擎支持对任务、事件、计划和 Webhook 进行灵活编排。这种模块化设计可实现可扩展、可复用且适配您环境的自动化：

* **将多个任务或事件分配给单个 Webhook** — 例如，您可以配置一个 Webhook 以通知外部系统，并让它由多种不同事件触发，例如同步失败、登录尝试或系统警报。这减少了重复并将外部集成集中管理。
* **由多个不同事件触发单个任务** — 例如，当特定用户登录时，或当计划的维护窗口开始时，启动一台虚拟机。这样可以整合逻辑，并在不同场景中复用任务定义。
* **创建一次计划并将其应用于多个任务** — 例如，定义一个每周维护窗口，并将其关联到多个更新、告警或关机任务。这有助于保持一致性并简化配置管理。

这种模块化设计可实现可扩展、可复用且适配您环境的自动化。

***

## 相关指南

* [创建自动化任务](/automate-protect-and-extend/zh/zi-dong-hua/create-tasks.md)
* [使用 Webhook](/automate-protect-and-extend/zh/zi-dong-hua/webhooks.md)
* [定义计划](/automate-protect-and-extend/zh/zi-dong-hua/schedules.md)

***


---

# 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.verge.io/automate-protect-and-extend/zh/zi-dong-hua/task-engine.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.
