nezhahq.github.io/assets/en_US_guide_tasks.md.XjHYAytW.js
2024-09-01 03:19:11 +00:00

2 lines
4.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as e,c as t,o,a4 as a}from"./chunks/framework.BmdFiWrL.js";const p=JSON.parse('{"title":"Task Management","description":"","frontmatter":{"outline":"deep"},"headers":[],"relativePath":"en_US/guide/tasks.md","filePath":"en_US/guide/tasks.md","lastUpdated":1725160726000}'),n={name:"en_US/guide/tasks.md"},s=a('<h1 id="task-management" tabindex="-1">Task Management <a class="header-anchor" href="#task-management" aria-label="Permalink to &quot;Task Management&quot;"></a></h1><p><strong>In the Tasks section, you can set up scheduled tasks, trigger tasks, and batch execute tasks on multiple servers.</strong></p><p>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.</p><h2 id="how-to-use" tabindex="-1">How to Use <a class="header-anchor" href="#how-to-use" aria-label="Permalink to &quot;How to Use&quot;"></a></h2><p>Go to the &quot;Tasks&quot; page in the admin panel and click &quot;Add Scheduled Task.&quot; When adding a scheduled task, you need to fill in the following parameters:</p><ul><li><p><strong>Name</strong>: Customize a task name.</p></li><li><p><strong>Task Type</strong>: Choose the type of task.</p><ul><li><strong>Scheduled Task</strong>: Executes periodically according to the schedule set below.</li><li><strong>Trigger Task</strong>: Only executed when triggered by an API call or notification rule, runs once per trigger.</li></ul></li><li><p><strong>Schedule</strong>: Set the schedule time (not enable when using trigger task type). The time format is <code>* * * * * *</code>, corresponding to <code>second minute hour day month weekday</code>. For more details, see <a href="https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format" target="_blank" rel="noreferrer">Cron Expression Format</a>.<br> For example: <code>0 0 3 * * *</code> means &quot;3 AM every day.&quot;</p></li><li><p><strong>Command</strong>: Set the command to execute, similar to writing Shell/Bat scripts, but it&#39;s recommended not to use new lines; connect multiple commands with <code>&amp;&amp;</code> or <code>&amp;</code>.<br> For example, to schedule a reboot, you can enter <code>reboot</code> here.</p></li><li><p><strong>Coverage</strong> and <strong>Specific Servers</strong>: Select rules to determine which Agents execute the scheduled task, similar to the settings on the &quot;Services&quot; page. When using the trigger task type, you can choose &quot;executed by the triggered server.&quot;</p></li><li><p><strong>Notification Group</strong>: Choose the notification methods you have set up on the &quot;Notifications&quot; page. <a href="/en_US/guide/notifications.html#flexible-notification-methods">Click here</a> for more details.</p></li><li><p><strong>Send Success Notification</strong>: Check this option to trigger a notification upon successful task execution.</p></li></ul><h2 id="managing-tasks" tabindex="-1">Managing Tasks <a class="header-anchor" href="#managing-tasks" aria-label="Permalink to &quot;Managing Tasks&quot;"></a></h2><p>To manage existing scheduled tasks, go to the &quot;Tasks&quot; page in the admin panel. For each task configuration, the three icons on the right are:</p><ul><li><strong>Execute Immediately</strong>: Click to ignore the scheduled time and execute the task immediately.</li><li><strong>Edit</strong>: Click to modify the task configuration.</li><li><strong>Delete</strong>: Delete the scheduled task.</li></ul><h2 id="frequently-asked-questions" tabindex="-1">Frequently Asked Questions <a class="header-anchor" href="#frequently-asked-questions" aria-label="Permalink to &quot;Frequently Asked Questions&quot;"></a></h2><ol><li><strong>Command not found error</strong><br> If a command fails to run with a &quot;command not found&quot; error, it may be a PATH environment variable issue. On Linux servers, you can add <code>source ~/.bashrc</code> at the beginning of the command or use the absolute path to execute the command.</li></ol>',11),i=[s];function r(c,l,d,u,h,g){return o(),t("div",null,i)}const k=e(n,[["render",r]]);export{p as __pageData,k as default};