> 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/create-tasks.md).

# 创建自动化任务

本页提供在 VergeOS 中创建任务的一般说明，包括如何配置基于事件和基于计划的触发器。

## 创建新任务

1. 导航到 **系统** > **任务仪表板**.
2. 点击 **新任务** 在左侧菜单中。
3. 配置任务字段：
   * **名称**：为任务输入一个描述性名称。
   * **描述** *（可选）*：添加管理备注或上下文。
   * **运行后删除任务**：可选择此选项，在任务完成后自动删除任务。
   * **对象类型**：选择应用程序中的相关部分。
   * **对象**：选择任务将应用到的具体目标（例如 VM、租户、网络）。
   * **动作**：选择要对目标对象执行的操作。不同对象有所不同。
   * **设置**：配置任何适用的选项。这些选项因对象和操作而异。某些操作（例如开机/关机）可能不需要设置。

{% hint style="success" %}
**新任务默认是&#x20;*****启用*****&#x20;的。若您需要时间验证其配置或延迟部署，可以禁用任务。**
{% endhint %}

4. 点击 **提交** 在页面底部保存任务。\
   任务仪表板将会显示。

***

## 使任务生效

要激活任务，请定义一个或多个 **事件触发器** 和/或 **计划触发器**.

{% hint style="success" %}
**以下说明从任务仪表板开始，任务创建后会立即显示该页面。若要稍后返回仪表板：转到 系统 > 任务仪表板 > 任务，然后双击列表中的任务。**
{% endhint %}

***

### 定义事件触发器

事件触发器允许任务在特定系统事件发生时运行。

1. 点击 **事件触发器** 任务仪表板上的卡片。

{% hint style="success" %}
**该卡片显示当前与任务关联的事件触发器数量。**
{% endhint %}

2. 点击 **新建** 在左侧菜单中。
3. 完成事件配置：
   * **类型**：选择对象类别（例如，警报、虚拟机、租户）。
   * **事件**：选择将触发任务的事件类型。可用选项取决于所选对象类型。
   * **对象实例/标签**:
     * **对象实例**：- 从下拉列表中选择该对象类型的特定实例（例如，选择的类型是“用户”——从下拉列表中选择某个特定用户 *用户* 下拉列表；“虚拟机”是所选类型——从下拉列表中选择某个特定 VM *虚拟机* 下拉列表。）\
       **或**
     * **标签**：选择 **使用标签** 选项，并从下拉列表中选择一个可用标签，以便基于具有相应标签的对象来触发事件。（例如，如果“虚拟机”是所选类型，并且在 *标签* 下拉列表中选择了“production”，则事件触发器对应于任何分配了“production”标签的 VM。）
   * **筛选设置**: *（可选）*：对于如下通用类型： *日志* 或 *警报*，您可以缩小触发条件范围：警报：按严重级别筛选（例如， *错误*）；日志：按日志类型（例如，系统、租户、SMTP 等）和级别（例如， *严重*, *审计*, *警告*).
4. 点击 **提交** 以保存事件触发器。\
   它现在将与所选任务关联。

***

### 定义计划触发器

计划触发器允许任务在特定时间或按重复周期运行。

1. 点击 **计划触发器** 任务仪表板上的卡片。

{% hint style="success" %}
**该卡片显示当前与任务关联的计划数量。**
{% endhint %}

2. 点击 **新建** 在左侧菜单中。
3. 选择一个 **计划** 从下拉列表中选择。\
   VergeOS 包含多个预装计划。要创建自定义计划，请参阅 [**计划指南**](/automate-protect-and-extend/zh/zi-dong-hua/schedules.md).
4. 点击 **提交** 以保存计划触发器。它现在将与所选任务关联。

***

## 相关指南

* [任务引擎概览](/automate-protect-and-extend/zh/zi-dong-hua/task-engine.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/create-tasks.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.
