优化更新中英文文档-管理面板-任务

This commit is contained in:
Kris
2024-05-14 02:25:55 +02:00
parent bbd57a50b1
commit 11c6091f8d
2 changed files with 57 additions and 54 deletions
+32 -28
View File
@@ -1,38 +1,42 @@
**In the task area, you can set up scheduled tasks, Trigger tasks, and multi-server batch execution tasks**
---
outline: deep
---
Nezha monitoring supports pushing commands to the Agent for execution, so this feature is very flexible and can be used to periodically back up the server in conjunction with restic, rclone. Periodically restart a service to reset the network connection. It can also be used with notifications to perform a task when a notification is triggered, such as running a script when the CPU is at high occupancy for a long period of time.
**In the Tasks section, you can set up scheduled tasks, trigger tasks, and batch execute tasks on multiple servers.**
## How to use
Go to the "Tasks" page of the admin panel and click "Add Scheduled Task"
To add a scheduled task you need to make the following settings:
+ `Name` - Customize a task name
Nezha Monitoring supports pushing commands to Agents for execution. This feature is highly flexible and can be used for regular backups using tools like restic or rclone, periodically restarting a service to reset network connections, or executing a task when an notification is triggered, such as running a script when CPU usage is high for an extended period.
+ `Task Type` - select the type of task
Scheduled Tasks - Tasks are executed periodically at the scheduled time set below
Trigger Tasks - Tasks that are triggered only by API or notification rules and are executed once per trigger
## How to Use
+ `Cron Expression` - (Not valid when using the trigger task type) Set schedule time, the Cron Expression is like: `* * * * * *` `sec min hour day month week`, see details in [CRON Expression Format](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format)
For example: `0 0 3 * * *` is `Every day at 3 o'clock`
Go to the "Tasks" page in the admin panel and click "Add Scheduled Task." When adding a scheduled task, you need to fill in the following parameters:
+ `Command` - Just like writing shell/bat scripts, **but line wrap is not recommended**, **Multiple Commands should be connected with `&&/&`**
For example, to execute a periodic reboot command, you can type `reboot` here
- **Name**: Customize a task name.
+ `Coverage` and `Specific Servers` - Similar to the settings on the Services page, select rules to determine which Agents need to execute scheduled tasks
When using the trigger task type, you can select `Only servers that are included in the notification rule`
- **Task Type**: Choose the type of task.
- **Scheduled Task**: Executes periodically according to the schedule set below.
- **Trigger Task**: Only executed when triggered by an API call or notification rule, runs once per trigger.
+ `Notification Group` - Select the notification method you have set up on the "Notification" page. [Click here](/en_US/guide/notifications.html#flexible-notification-methods) for more information
- **Schedule**: Set the schedule time (not enable when using trigger task type). The time format is `* * * * * *`, corresponding to `second minute hour day month weekday`. For more details, see [Cron Expression Format](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format).
For example: `0 0 3 * * *` means "3 AM every day."
+ `Send Success Notification` - When this item is activated, a message notification will be triggered when the task is successfully executed
<br/>
- **Command**: Set the command to execute, similar to writing Shell/Bat scripts, but it's recommended not to use new lines; connect multiple commands with `&&` or `&`.
For example, to schedule a reboot, you can enter `reboot` here.
## Manage tasks
To manage existing scheduled tasks, you can go to the "Tasks" page in the administration panel
Select a task configuration and the three icons on the right, which are:
+ `Execute Now` - When clicked, the scheduled time will be ignored and the task will be executed immediately
+ `Edit` - Click to modify the task configuration
+ `Delete` - Delete this scheduled task
<br/>
- **Coverage** and **Specific Servers**: Select rules to determine which Agents execute the scheduled task, similar to the settings on the "Services" page. When using the trigger task type, you can choose "executed by the triggered server."
## FAQ
1. Command not found
Command not found may cause by missing PATH environment variable, for Linux Server, you may try adding `source ~/.bashrc` at beginning of your command or execute by absolute path.
- **Notification Group**: Choose the notification methods you have set up on the "Notifications" page. [Click here](/en_US/guide/notifications.html#flexible-notification-methods) for more details.
- **Send Success Notification**: Check this option to trigger a notification upon successful task execution.
## Managing Tasks
To manage existing scheduled tasks, go to the "Tasks" page in the admin panel. For each task configuration, the three icons on the right are:
- **Execute Immediately**: Click to ignore the scheduled time and execute the task immediately.
- **Edit**: Click to modify the task configuration.
- **Delete**: Delete the scheduled task.
## Frequently Asked Questions
1. **Command not found error**
If a command fails to run with a "command not found" error, it may be a PATH environment variable issue. On Linux servers, you can add `source ~/.bashrc` at the beginning of the command or use the absolute path to execute the command.