> 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 中创建自动化任务的分步说明，包括如何配置基于事件和基于计划的触发器来实现系统自动化。

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

## 创建新任务

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

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

4. 点击 **提交** ，以保存任务。\
   任务仪表板将会出现。

***

## 将任务付诸执行

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

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

***

### 定义事件触发器

事件触发器允许任务响应特定的系统事件而运行。

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

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

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

***

### 定义计划触发器

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

{% hint style="info" %}
计划时间以集群/系统时间进行评估，而不是您浏览器的本地时间。设置为 18:00 的计划会在集群时间 18:00 运行，不受您浏览器时区的影响。
{% endhint %}

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.
