跳到主要内容

ecs command

管理 ECS 云助手命令模板与执行记录

运行 ecctl ecs command <action> -h 查看用法,或 ecctl schema ecs.command.<action> --full 获取该命令完整的结构化规格——每个参数与行为,便于 Agent 读取和填参。

create

ecctl ecs command create [flags]

创建云助手命令模板

  • 类型:mutation · 风险:medium
  • 通过 ClientToken 幂等。
API调用时机用途
CreateCommand每次执行命令时执行资源操作。
DescribeCommands每次执行命令时读取资源视图。
参数类型必填说明
--command-contentstring在实例上执行的命令内容
--namestring云助手命令名称
--regionstringAlibaba Cloud region
--typestring云助手命令类型
--command-timeoutinteger命令超时时间,单位秒
--content-encodingstring命令内容编码方式
--descriptionstring云助手命令描述
--enable-parameterboolean启用命令中的自定义参数
--launcherstring命令启动器
--resource-groupstring资源组 ID
--tagkey_value标签赋值 key=value
--working-dirstring命令工作目录

update

ecctl ecs command update <id> [flags]

更新命令模板或执行记录属性

  • 类型:mutation · 风险:medium
API调用时机用途
ModifyInvocationAttribute指定 --invocation-id执行资源操作。
ModifyCommand指定 &lt;id>执行资源操作。
DescribeInvocations指定 --invocation-id 且未指定 --no-wait读取资源视图。
DescribeCommands指定 &lt;id> 且未指定 --no-wait读取资源视图。
参数类型必填说明
--regionstringAlibaba Cloud region
--command-contentstring在实例上执行的命令内容
--command-timeoutinteger命令超时时间,单位秒
--descriptionstring云助手命令描述
--frequencystring定时执行频率(cron 表达式)
--invocation-idstring执行记录 ID
--launcherstring命令启动器
--namestring云助手命令名称
--repeat-modestring执行重复模式
--timedboolean是否为定时执行
--working-dirstring命令工作目录

delete

ecctl ecs command delete <id> [flags]

删除命令模板

  • 类型:mutation · 风险:high
  • 同步:等待 absent(waiter deleted_after_delete,超时 120s);用 --no-wait 跳过等待。
API调用时机用途
DeleteCommand每次执行命令时执行资源操作。
DescribeCommands未指定 --no-wait轮询等待资源达到目标状态。(重复调用)
参数类型必填说明
--regionstringAlibaba Cloud region

get

ecctl ecs command get <id> [flags]

获取命令模板、执行记录或执行结果

  • 类型:read · 风险:low
API调用时机用途
DescribeInvocations指定 --invocation-id读取资源视图。
DescribeInvocationResults指定 --with-results读取资源视图。
DescribeCommands指定 &lt;id>读取资源视图。
参数类型必填说明
--regionstringAlibaba Cloud region
--fieldsstring要包含的资源字段,使用逗号分隔
--include-historyboolean返回历史执行结果
--include-outputboolean返回执行输出内容
--instancestring实例 ID 过滤
--invocation-idstring执行记录 ID
--invoke-record-statusstring执行结果状态过滤
--with-resultsboolean返回执行结果

list

ecctl ecs command list <id> [flags]

列出命令模板或执行记录

  • 类型:read · 风险:low
API调用时机用途
DescribeInvocations指定 --invocations读取资源视图。
DescribeCommands未指定 --invocations读取资源视图。
参数类型必填说明
--regionstringAlibaba Cloud region
--content-encodingstring命令内容编码方式
--fieldsstring要包含的资源字段,使用逗号分隔
--filterkey_value过滤表达式 key=value
--include-outputboolean返回执行输出内容
--invocationsboolean列出执行记录而非命令模板
--limitinteger最多返回资源数量(默认:50
--next-tokenstring下一页查询 token

invoke

ecctl ecs command invoke <id> [flags]

在目标实例上执行命令

  • 类型:mutation · 风险:high
  • 同步:等待 Finished(waiter finished_after_invoke,超时 600s);用 --no-wait 跳过等待。
  • 通过 ClientToken 幂等。
API调用时机用途
InvokeCommand每次执行命令时执行资源操作。
DescribeInvocations未指定 --no-wait轮询等待资源达到目标状态。(重复调用)
DescribeInvocationResults未指定 --no-wait读取资源视图。
参数类型必填说明
--instance-idsarray目标实例 ID 列表
--regionstringAlibaba Cloud region
--container-idstring容器 ID
--container-namestring容器名称
--frequencystring定时执行频率(cron 表达式)
--parametersstring命令参数(JSON 对象)
--repeat-modestring执行重复模式
--resource-groupstring资源组 ID
--tagkey_value标签赋值 key=value
--timedboolean是否为定时执行
--usernamestring执行命令的用户名
--windows-password-namestringWindows 加密密码键名

stop

ecctl ecs command stop <invocation-id> [flags]

停止正在执行的命令

  • 类型:mutation · 风险:medium
  • 同步:等待 Stopped(waiter stopped_after_stop,超时 300s);用 --no-wait 跳过等待。
API调用时机用途
StopInvocation每次执行命令时执行资源操作。
DescribeInvocations未指定 --no-wait轮询等待资源达到目标状态。(重复调用)
DescribeInvocations未指定 --no-wait读取资源视图。
DescribeInvocationResults未指定 --no-wait读取资源视图。
参数类型必填说明
--regionstringAlibaba Cloud region
--forceboolean在 API 支持时强制停止执行(必须显式指定)(默认:false
--instance-idsarray目标实例 ID 列表