立即执行脚本
<p class="shortdesc">您可以选择立即执行已经添加的脚本。</p>
<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">
<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>
</li><li class="li step stepexpand">
<span class="ph cmd">在<span class="keyword wintitle">快速脚本执行</span>页面,完成如下配置。</span>
<div class="itemgroup info">
<img class="image" id="Carriescript__image_sz4_thr_bkb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20201407174753-187ba92f92b8.png" width="800">
<table class="table frame-all" id="Carriescript__table_aqn_vhr_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="Carriescript__table_aqn_vhr_bkb__entry__1">配置项</th>
<th class="entry" id="Carriescript__table_aqn_vhr_bkb__entry__2">说明</th>
</tr>
</thead><tbody class="tbody">
<tr class="row">
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">任务名称</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__2 ">
<p class="p" id="Carriescript__d21e108">关于该脚本执行任务的名称。</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">任务描述</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__2 ">
<p class="p" id="Carriescript__d21e124">关于该脚本执行任务的描述。</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">脚本类型</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__2 ">
<p class="p" id="Carriescript__d21e140">根据主机类型选择脚本类型:</p>
<ul class="ul" id="Carriescript__d21e143">
<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="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">目标机器</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__2 ">
<div class="p" id="Carriescript__d21e177">设置脚本需要在哪些主机上执行。(根据脚本类型筛选出对应的主机,Shell类型对应Linux主机,PowerShell类型对应Windows主机)。目前支持两种方式选择主机:<ul class="ul" id="Carriescript__d21e179">
<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="Carriescript__d21e199" 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="Carriescript__d21e226" 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="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">脚本来源</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__2 ">
<p class="p">目前支持四种方式:</p>
<ul class="ul" id="Carriescript__d21e246">
<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="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">脚本内容</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__2 ">
<p class="p" id="Carriescript__d21e285">在主机执行的脚本的具体内容。</p>
<div class="note note note_note" id="Carriescript__d21e288"><span class="note__title">说明:</span> 所填写内容不能超过30000字符。</div>
</td>
</tr>
<tr class="row">
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">脚本参数</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_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="Carriescript__table_aqn_vhr_bkb__entry__1 ">
<p class="p"><span class="ph uicontrol">超时时间</span></p>
</td>
<td class="entry" headers="Carriescript__table_aqn_vhr_bkb__entry__2 ">
<p class="p" id="Carriescript__d21e335">设置任务执行超时时间,如果超过了设定的时间,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>
</li></ol></section>
提交成功!非常感谢您的反馈,我们会继续努力做到更好!