2 lines
3.9 KiB
JavaScript
2 lines
3.9 KiB
JavaScript
import{_ as t,c as o,o as e,a4 as r}from"./chunks/framework.BmdFiWrL.js";const u=JSON.parse('{"title":"任务管理","description":"","frontmatter":{"outline":"deep"},"headers":[],"relativePath":"guide/tasks.md","filePath":"guide/tasks.md","lastUpdated":1720901424000}'),a={name:"guide/tasks.md"},s=r('<h1 id="任务管理" tabindex="-1">任务管理 <a class="header-anchor" href="#任务管理" aria-label="Permalink to "任务管理""></a></h1><p><strong>在任务区域中,可以设置计划任务,触发任务,多服务器批量执行任务</strong></p><p>哪吒监控支持推送命令到 Agent 执行,此功能非常灵活。使用此功能可以定期结合 restic、rclone 给服务器备份,定期重启某项服务来重置网络连接。也可以配合告警通知,在触发告警时执行某项任务,例如在 CPU 长时间高占用的情况下运行某个脚本。</p><h2 id="使用方法" tabindex="-1">使用方法 <a class="header-anchor" href="#使用方法" aria-label="Permalink to "使用方法""></a></h2><p>进入管理面板的“任务”页,点击“添加计划任务”。添加计划任务时,你需要填入以下参数:</p><ul><li><p><strong>名称</strong>:自定义一个任务名称。</p></li><li><p><strong>任务类型</strong>:选择任务的类型。</p><ul><li><strong>计划任务</strong>:按下方设置的计划时间,周期性执行任务。</li><li><strong>触发任务</strong>:仅被 API 或告警规则触发的任务,每次触发执行一次。</li></ul></li><li><p><strong>计划</strong>:设置计划时间(使用触发任务类型时不生效),时间格式为:<code>* * * * * *</code>,分别对应<code>秒 分 时 天 月 星期</code>,详情见<a href="https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format" target="_blank" rel="noreferrer">计划表达式格式</a>。<br> 例如:<code>0 0 3 * * *</code> 对应为“每天 3 点”。</p></li><li><p><strong>命令</strong>:设置需要执行的命令,就像写 Shell/Bat 脚本一样,但不推荐换行,多个命令使用 <code>&&/&</code> 连接。<br> 例如执行定期重启命令,可以在这里输入 <code>reboot</code>。</p></li><li><p><strong>覆盖范围</strong>和<strong>特定服务器</strong>:选择规则来确定哪些 Agent 执行计划任务,类似于“服务”页中的设置。使用触发任务类型时,可选择“由触发的服务器执行”。</p></li><li><p><strong>通知方式组</strong>:选择你已经在“告警”页设置好的通知方式,<a href="/guide/notifications.html#灵活的通知方式">点击这里</a>了解详情。</p></li><li><p><strong>推送成功的消息</strong>:勾选此项,任务执行成功后会触发消息通知。</p></li></ul><h2 id="管理任务" tabindex="-1">管理任务 <a class="header-anchor" href="#管理任务" aria-label="Permalink to "管理任务""></a></h2><p>如需对已有的计划任务进行管理,可以前往管理面板中的“任务”页。选择一条任务配置,右侧的三个图标分别是:</p><ul><li><strong>立即执行</strong>:点击后将忽略计划时间,立刻执行任务。</li><li><strong>编辑</strong>:点击可以修改任务配置。</li><li><strong>删除</strong>:删除这条计划任务。</li></ul><h2 id="常见问题" tabindex="-1">常见问题 <a class="header-anchor" href="#常见问题" aria-label="Permalink to "常见问题""></a></h2><ol><li><strong>xxx 命令找不到</strong><br> 如果运行失败,提示 xxx 命令找不到,可能是 PATH 环境变量的问题。在 Linux 服务器上,可以在命令开头加入 <code>source ~/.bashrc</code>,或者使用绝对路径执行命令。</li></ol>',11),n=[s];function i(l,c,d,g,p,h){return e(),o("div",null,n)}const m=t(a,[["render",i]]);export{u as __pageData,m as default};
|