快速创建并执行脚本执行任务

<p class="shortdesc">通过快速执行(脚本执行任务),可以帮助您快速地创建并在多台主机批量执行一次脚本执行任务。</p> <section class="section context" id="script__context_dy3_1xz_bkb"><div class="tasklabel"><h2 class="doc-tairway">背景信息</h2></div> <p class="p">您可以通过手动录入、从本地上传、从公共平台上传及已有脚本克隆四种方式导入脚本并批量执行。</p> </section> <section><div class="tasklabel"><h2 class="doc-tairway">操作步骤</h2></div><ol class="ol steps"><li class="li step stepexpand"> <span class="ph cmd">登录<a class="xref" href="https://pinganyun.com/console/osp" target="_blank">系统管理服务OSP控制台</a>。</span> </li><li class="li step stepexpand" id="script__step_edm_kyj_mlb"> <span class="ph cmd">在左侧导航栏中,单击<span class="ph menucascade"><span class="ph uicontrol">作业管理</span><abbr> > </abbr><span class="ph uicontrol">快速执行</span></span>。</span> </li><li class="li step stepexpand"> <span class="ph cmd">在<span class="keyword wintitle">快速脚本执行</span>页面,选择<span class="ph uicontrol">任务类型</span>为<span class="ph uicontrol">脚本执行</span>。</span> <div class="itemgroup info"> <img class="image" id="script__image_kmh_sdl_bkb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20201407174751-15430f699307.png"> </div> </li><li class="li step stepexpand" id="script__step_vk2_vxz_bkb"> <span class="ph cmd">完成后,您需要进行如下配置。</span> <div class="itemgroup info"> <img class="image" id="script__image_k3n_ydl_bkb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20201407174751-1306969e90e1.png"> <table class="table frame-all" id="script__table_gjj_zdl_bkb"><caption></caption><colgroup><col style="width:34.01360544217687%"><col style="width:65.98639455782312%"></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="script__table_gjj_zdl_bkb__entry__1">配置项</th> <th class="entry" id="script__table_gjj_zdl_bkb__entry__2">说明</th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">任务名称</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <p class="p" id="script__p_hvg_3hr_bkb">关于该脚本执行任务的名称。</p> </td> </tr> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">任务描述</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <p class="p" id="script__p_r2l_3hr_bkb">关于该脚本执行任务的描述。</p> </td> </tr> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">脚本类型</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <p class="p" id="script__p_c3q_3hr_bkb">根据主机类型选择脚本类型:</p> <ul class="ul" id="script__ul_hz1_hjt_bkb"> <li class="li">若主机为<strong class="ph b">Linux</strong>类型,则选择脚本类型为<span class="ph uicontrol">Shell</span>。</li> <li class="li">若主机为<strong class="ph b">Windows</strong>类型,则选择脚本类型为<span class="ph uicontrol">PowerShell</span>。</li> </ul> </td> </tr> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">目标机器</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <div class="p" id="script__p_cqz_pgl_bkb">设置脚本需要在哪些主机上执行。(根据脚本类型筛选出对应的主机,Shell类型对应Linux主机,PowerShell类型对应Windows主机)。目前支持两种方式选择主机:<ul class="ul" id="script__ul_kyt_4gl_bkb"> <li class="li"> <p class="p"><strong class="ph b">方式一:选择主机</strong></p> <p class="p">单击<span class="ph uicontrol">+选择机器</span>,在弹出的<span class="keyword wintitle">主机选择</span>页面中,勾选一个或者多个主机,然后单击<span class="ph uicontrol">选择</span>。</p> <img class="image" id="script__image_vpq_hkt_bkb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20201407174751-16a350799ebd.png" width="500"> </li> <li class="li"> <p class="p"><strong class="ph b">方式二:导入主机</strong></p> <p class="p">单击<span class="ph uicontrol">快速导入</span>,在<span class="ph uicontrol">主机列表</span>框中,输入主机名称或者IP地址,输入完成后单击<span class="ph uicontrol">主机匹配</span>。匹配无误后,单击<span class="ph uicontrol">确定</span>。</p> <div class="note note note_note"><span class="note__title">说明:</span> 输入的IP或主机名称,可以用“英文逗号,”、“英文分号;”、“|”或“换行符”将多个主机名进行分隔。</div> <img class="image" id="script__image_p5l_tkt_bkb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20201407174751-1ef2ca479d9b.png" width="500"> </li> </ul></div> </td> </tr> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">脚本来源</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <p class="p">目前支持四种方式:</p> <ul class="ul" id="script__ul_obg_j2l_bkb"> <li class="li"><span class="ph uicontrol">手工录入</span>:直接在脚本编辑器中,编写脚本。</li> <li class="li"><span class="ph uicontrol">本地上传</span>:根据脚本类型,选择一个本地计算机的脚本文件,并将脚本内容填充到脚本编辑器中。<div class="note note note_note"><span class="note__title">说明:</span> 脚本文件大小不超过30K。</div></li> <li class="li"><span class="ph uicontrol">脚本克隆</span>:从您所管理的脚本中,选择一个脚本,将内容填充到脚本编辑器。</li> <li class="li"><span class="ph uicontrol">公共脚本</span>:从公共平台提供的脚本中,选择一个脚本,将内容填充到脚本编辑器。</li> </ul> </td> </tr> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">脚本内容</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <p class="p" id="script__p_pkk_jhr_bkb">在主机执行的脚本的具体内容。</p> <div class="note note note_note" id="script__note_m14_rkr_dkb"><span class="note__title">说明:</span> 所填写内容不能超过30000字符。</div> </td> </tr> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">脚本参数</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <p class="p">单击<span class="ph uicontrol">立即执行</span>后,系统会把脚本内容保存成一个脚本文件,并根据操作系统使用Powershell、CMD或Bash来执行,脚本参数内的内容会被拼接到实际执行的命令的末尾。</p> <p class="p">例如,假设脚本名为<code class="ph codeph">abc.ps1</code>并使用Powershell来执行脚本,脚本参数中的内容为<code class="ph codeph">key1=value1,key2=value2</code>,则最终在目标服务器中执行的命令为<code class="ph codeph">powershell -File abc.ps1 key1=value1 key2=value2</code>。</p> </td> </tr> <tr class="row"> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__1 "> <p class="p"><span class="ph uicontrol">超时时间</span></p> </td> <td class="entry" headers="script__table_gjj_zdl_bkb__entry__2 "> <p class="p" id="script__p_dhs_h3l_bkb">设置任务执行超时时间,如果超过了设定的时间,CloudAgent会结束任务进程。单位分钟,范围1~30,空设置将默认超时时间为30分钟。</p> </td> </tr> </tbody></table> </div> </li><li class="li step stepexpand"> <span class="ph cmd">完成配置后,单击<span class="ph uicontrol">立即执行</span>。</span> <div class="itemgroup info"> <div class="p" id="script__p_pmr_f3q_dkb"> <div class="note note note_note"><span class="note__title">说明:</span> 配置完成后,若单击<span class="ph uicontrol">另存为</span>,该任务会在<span class="ph uicontrol">任务管理</span>中保存为一个任务。</div> </div> </div> </li></ol></section> <section class="section result" id="script__result_edz_mfl_bkb"><div class="tasklabel"><h2 class="doc-tairway">执行结果</h2></div> <p class="p">执行后,页面会跳转到脚本<span class="keyword wintitle">执行详情</span>页面。您可以查看<span class="ph uicontrol">任务概况</span>和<span class="ph uicontrol">机器执行列表</span>。</p> <div class="p"> <img class="image" id="script__image_ftl_hjq_dkb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20201407174752-136be9db9752.png" width="800"> </div> </section>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

工单支持

解决云产品相关技术问题