DescribeCommandInvocations - 查询命令执行列表和状态

更新时间:
复制 MD 格式

查询命令助手执行命令的列表和状态。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

swas-open:DescribeCommandInvocations

get

*全部资源

*

请求参数

名称

类型

必填

描述

示例值

RegionId

string

地域 ID。您可以调用 ListRegions 查询可用地域。

cn-hangzhou

InstanceId

string

指定的轻量应用服务器的实例 ID。

ace0706b2ac4454d984295a94213****

CommandId

string

命令 ID。您可以通过接口 DescribeCommands 查询所有可用的 CommandId。

c-sh02yh0932w****

InvokeId

string

命令执行 ID。

t-hz02p9545t6****

CommandName

string

命令名称。如果同时设置了 InstanceId 参数,则该参数不生效。

testName

InvocationStatus

string

命令执行的总执行状态,总执行状态取决于本次调用的全部实例的共同执行状态,可能值:

  • Pending:系统正在校验或发送命令。存在至少一台实例的命令执行状态为 Pending,则总执行状态为 Pending。

  • Running:命令正在实例上运行。存在至少一台实例的命令执行状态为 Running,则总执行状态为 Running。

  • Success:各个实例上的命令执行状态均为 Stopped 或 Success,且至少一个实例的命令执行状态是 Success,则总执行状态为 Success。
    • 立即运行的任务:命令执行完成,且退出码为 0。

  • Failed:各个实例上的命令执行状态均为 Stopped 或 Failed,则总执行状态为 Failed。实例上的命令执行状态一项或多项为以下状态时,返回值均为 Failed 状态:
    • 命令校验失败(Invalid)

    • 命令发送失败(Aborted)

    • 命令执行完成但退出码非 0(Failed)

    • 命令执行超时(Timeout)

    • 命令执行异常(Error)

  • Stopping:正在停止任务。存在至少一台实例的命令执行状态为 Stopping,则总执行状态为 Stopping。

  • Stopped:任务已停止。所有实例的命令执行状态是 Stopped,则总执行状态为 Stopped。实例上的命令执行状态为以下状态时,返回值均为 Stopped 状态:
    • 任务已取消(Cancelled)

    • 任务已终止(Terminated)

  • PartialFailed:部分实例执行成功且部分实例执行失败。各个实例的命令执行状态均为 Success、Failed 或 Stopped,则总执行状态为 PartialFailed。

说明

返回参数中的InvokeStatus与该参数意义相似,但建议您查看该返回值。

Success

CommandType

string

命令类型。可能值:

  • RunBatScript:适用于 Windows 实例的 Bat 命令。

  • RunPowerShellScript:适用于 Windows 实例的 PowerShell 命令。

  • RunShellScript:适用于 Linux 实例 Shell 命令。

RunPowerShellScript

PageNumber

string

当前页码。起始值:1。默认值:1。

1

PageSize

string

分页查询时设置的每页行数。

最大值:50。

默认值:10。

10

返回参数

名称

类型

描述

示例值

object

Schema of Response

RequestId

string

请求 ID。

30637AD6-D977-4833-A54C-CC89483E****

TotalCount

integer

总条数。

10

PageNumber

integer

查询结果的页码。

1

PageSize

integer

分页查询时设置的每页行数。

10

CommandInvocations

array<object>

命令执行列表。

array<object>

命令执行信息结构体。

InvokeId

string

命令执行 ID。

t-hz0373jyzxt****

CreationTime

string

命令创建时间,格式为 YYYY-MM-DDThh:mm:ss。

2023-04-27T10:11:58

CommandId

string

命令 ID。

c-hy0338xh28r****

InvocationStatus

string

命令执行的状态。可能值:

  • Pending:系统正在校验或发送命令。

  • Invalid:指定命令类型或参数有误。

  • Aborted:向实例发送命令失败。实例必须在运行中,且命令可以 1 分钟内发送完成。

  • Running:命令正在实例上执行。

  • Success:命令执行完成,且退出码为 0。

  • Failed:命令执行完成,且退出码非 0。

  • Error:命令执行时发生异常无法继续。

  • Timeout:命令执行超时。

  • Cancelled:命令的执行动作已经取消,命令未曾启动。

  • Stopping:正在停止执行的命令。

  • Terminated:命令执行时被终止。

Success

CommandName

string

命令名称。

testCommandName

CommandType

string

命令类型。

RunShellScript

CommandDescription

string

命令描述。

testDescription

Username

string

执行命令的用户名称。

root

WorkingDir

string

命令执行的路径。

c:\wwwroot

Timeout

integer

超时时间,单位为秒(s)。

60

CommandContent

string

命令内容。

echo 123

Parameters

string

命令中包含自定义参数。如果没有参数,默认为{}.

{}

InvokeInstances

array<object>

执行目标实例列表。

object

执行目标实例信息结构体。

InstanceId

string

轻量应用服务器的实例 ID。

2445f4aecdac4b71ba2c7e3a7ccf****

StartTime

string

命令在实例中开始执行的时间。时间采用 UTC(Z)时区,格式为 YYYY-MM-DDThh:mm:ssZ。

2023-05-09T03:32:24Z

FinishTime

string

命令进程的结束时间。时间采用 UTC(Z)时区,格式为 YYYY-MM-DDThh:mm:ssZ。

2023-04-03T02:42:29Z

InvocationStatus

string

单台实例的命令进度状态,可能值:

  • Pending:系统正在校验或发送命令。

  • Invalid:指定命令类型或参数有误。

  • Aborted:向实例发送命令失败。实例必须在运行中,且命令可以 1 分钟内发送完成。

  • Running:命令正在实例上运行。

  • Success:
    • 单次执行的命令:命令执行完成,且退出码为 0。

    • 定时执行的命令:上一次运行成功且退出码为 0,且指定的时间已结束。

  • Failed:
    • 单次执行的命令:命令执行完成,且退出码非 0。

    • 定时执行的命令:上一次运行成功且退出码非 0,且指定的时间将中止。

  • Error:命令执行时发生异常无法继续。

  • Timeout:命令执行超时。

  • Cancelled:命令的执行动作已经取消,命令未曾启动。

  • Stopping:正在停止任务。

  • Terminated:命令运行时被终止。

Running

Output

string

命令执行后的输出信息。

OutputMsg

ExitCode

integer

命令的退出码。

  • Linux 实例为 Shell 命令的退出码。

  • Windows 实例为 Bat 或者 PowerShell 命令的退出码。

0

ErrorInfo

string

命令的下发失败或执行失败原因的详情,可能值:

  • 空:命令执行正常。

  • the specified instance does not exists:指定的实例不存在或已释放。

  • the instance has released when create task:执行命令期间,该实例被释放。

  • the instance is not running when create task:命令执行时,该实例不在运行中。

  • the command is not applicable:命令不适用于指定的实例。

  • the specified account does not exists:指定的账号不存在。

  • the specified directory does not exists:指定的目录不存在。

  • the cron job expression is invalid:指定的周期表达式不合法。

  • the aliyun service is not running on the instance:云助手客户端未运行。

  • the aliyun service in the instance does not response:云助手客户端无响应。

  • the aliyun service in the instance is upgrading now:云助手客户端正在升级中。

  • the aliyun service in the instance need upgrade:云助手客户端需要升级。

  • the command delivery has been timeout:发送命令超时。

  • the command execution has been timeout:命令执行超时。

  • the command execution got an exception:命令执行发生异常。

  • the command execution has been interrupted:命令执行被中断。

  • the command execution exit code is not zero:命令执行结束,退出码非 0。

the specified instance does not exists

ErrorCode

string

命令的下发失败或执行失败原因的代码,可能值:

  • 空:命令执行正常。

  • InstanceNotExists:指定的实例不存在或已释放。

  • InstanceReleased:执行命令期间,该实例被释放。

  • InstanceNotRunning:命令执行时,该实例不在运行中。

  • CommandNotApplicable:命令不适用于指定的实例。

  • AccountNotExists:指定的账号不存在。

  • DirectoryNotExists:指定的目录不存在。

  • BadCronExpression:指定的周期表达式不合法。

  • ClientNotRunning:云助手客户端未运行。

  • ClientNotResponse:云助手客户端无响应。

  • ClientIsUpgrading:云助手客户端正在升级中。

  • ClientNeedUpgrade:云助手客户端需要升级。

  • DeliveryTimeout:发送命令超时。

  • ExecutionTimeout:命令执行超时。

  • ExecutionException:命令执行发生异常。

  • ExecutionInterrupted:命令执行被中断。

  • ExitCodeNonzero:命令执行结束,退出码非 0。

InstanceNotExists

示例

正常返回示例

JSON格式

{
  "RequestId": "30637AD6-D977-4833-A54C-CC89483E****",
  "TotalCount": 10,
  "PageNumber": 1,
  "PageSize": 10,
  "CommandInvocations": [
    {
      "InvokeId": "t-hz0373jyzxt****",
      "CreationTime": "2023-04-27T10:11:58",
      "CommandId": "c-hy0338xh28r****",
      "InvocationStatus": "Success",
      "CommandName": "testCommandName",
      "CommandType": "RunShellScript",
      "CommandDescription": "testDescription",
      "Username": "root",
      "WorkingDir": "c:\\wwwroot",
      "Timeout": 60,
      "CommandContent": "echo 123",
      "Parameters": "{}",
      "InvokeInstances": [
        {
          "InstanceId": "2445f4aecdac4b71ba2c7e3a7ccf****",
          "StartTime": "2023-05-09T03:32:24Z",
          "FinishTime": "2023-04-03T02:42:29Z",
          "InvocationStatus": "Running",
          "Output": "OutputMsg",
          "ExitCode": 0,
          "ErrorInfo": "the specified instance does not exists",
          "ErrorCode": "InstanceNotExists"
        }
      ]
    }
  ]
}

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情