Queries the execution list and state of Cloud Assistant commands.

Description

  • After you run a command, the command may not succeed or deliver the expected results. You can call this operation to query the execution results.
  • You can query the information about command executions within the last two weeks. A maximum of 100,000 pieces of execution information can be retained.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeInvocations

The operation that you want to perform. Set the value to DescribeInvocations.

RegionId String Yes cn-hangzhou

The region ID of the security group. You can call the DescribeRegions operation to query the most recent region list.

InvokeId String No t-hz0jdfwd9f****

The execution ID of the command.

CommandId String No c-hz0jdfwcsr****

The ID of the command. You can call the DescribeCommands operation to query all available command IDs.

CommandName String No CommandTestName

The name of the command.

CommandType String No RunShellScript

The type of the command. If this parameter and InstanceId are both specified, this parameter does not take effect.

Timed Boolean No true

Specifies whether to query the commands to be automatically run. Valid values:

  • true: queries the commands that meet the following requirements: The commands are run by calling the RunCommand or InvokeCommand operation with RepeatMode set to Period, NextRebootOnly, or EveryReboot. The executions of the commands are either not canceled and not complete or not stopped and not complete.
  • false: queries commands that meet the following requirements:
    • The commands are run by calling the RunCommand or InvokeCommand operation with RepeatMode set to Once.
    • The executions of the commands are canceled, stopped, or complete.

Default value: false.

InvokeStatus String No Finished

The overall execution state of the command. The value of this parameter depends on the execution states on all the involved instances. Valid values:

  • Running:
    • Recurring execution: Before you manually stop the execution of the command, the overall execution state is always Running.
    • One-time execution: If the execution is in progress on one or more instances, the overall execution state is Running.
  • Finished:
    • Recurring execution: The overall execution state can never be Finished.
    • One-time execution: The execution is complete on all instances, or the execution is manually stopped on some instances and is complete on the other instances.
  • Failed:
    • Recurring execution: The overall execution state can never be Failed.
    • One-time execution: The execution fails on all instances.
  • PartialFailed:
    • Recurring execution: The overall execution state can never be PartialFailed.
    • One-time execution: The execution fails on some instances.
  • Stopped: The execution is stopped.
InstanceId String No i-bp1i7gg30r52z2em****

The ID of the instance. When you specify this parameter, the system queries all the execution records of all the commands that run on the instance.

ContentEncoding String No PlainText

The encoding mode of the CommandContent and Output response parameters. Valid values:

  • PlainText: returns the original command content and command outputs.
  • Base64: returns the Base64-encoded command content and command outputs.

Default value: Base64.

IncludeOutput Boolean No false

Specifies whether to return the command outputs in the response.

  • true: The command outputs are returned. When this parameter is set to true, you must specify InvokeId, InstanceId, or both.
  • false: The command outputs are not returned.

Default value: false.

PageNumber Long No 1

The number of the page to return.

Pages start from page 1.

Default value: 1.

PageSize Long No 10

The number of entries to return on each page.

Maximum value: 50.

Default value: 10.

RepeatMode String No Once

Specifies the execution mode of the command. Valid values:

  • Once: The command is immediately run.
  • Period: The command is run on a regular basis.
  • NextRebootOnly: The command is automatically run the next time the instance starts.
  • EveryReboot: The command is automatically run every time the instance starts.

This parameter is empty by default, which indicates that the commands in all the modes are queried.

Response parameters

Parameter Type Example Description
PageSize Long 10

The number of entries returned on each page.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The ID of the request.

PageNumber Long 1

The page number of the returned page.

TotalCount Long 1

The total number of the commands.

Invocations Array of Invocation

Details about the command executions.

Invocation
CreationTime String 2020-01-19T09:15:46Z

The time when the task was created.

Frequency String 0 */20 * * * *

The schedule on which to run the command. For information about the value specifications, see Cron expression.

InvocationStatus String Running

The overall execution status of the command. The value of this parameter depends on the execution status on all the involved instances. Valid values:

  • Pending: The system is verifying or sending the command. When the execution state on at least one instance is Pending, the overall execution state is Pending.
  • Scheduled: The recurring command is sent and waiting to be run. When the execution state on at least one instance is Scheduled, the overall execution state is Scheduled.
  • Running: The command is being run on the instances. When the execution state on at least one instance is Running, the overall execution state is Running.
  • Success: When the execution state on at least one instance is Success and the execution state on the other instances is Stopped or Success, the overall execution state is Success.
    • One-time execution: The execution is complete, and the exit code is 0.
    • Recurring execution: The last execution succeeds, and the exit code is 0. The specified recurring period during which the command is run ends.
  • Failed: When the execution state on all instances is Stopped or Failed, the overall execution state is Failed. When the execution state on an instance is one of the following values, Failed is returned as the overall execution state:
    • Invalid: The command is invalid.
    • Aborted: The command failed to be sent.
    • Failed: The command execution is complete, but the exit code is not 0.
    • Timeout: The execution times out.
    • Error: An error occurs when the command is being run.
  • Stopping: The execution is being stopped. When the execution state on at least one instance is Stopping, the overall execution state is Stopping.
  • Stopped: The execution is stopped. When the execution state on all instances is Stopped, the overall execution state is Stopped. When the execution state on an instance is one of the following values, Stopped is returned as the overall execution state:
    • Cancelled: The execution is canceled.
    • Terminated: The execution is terminated.
  • PartialFailed: The execution succeeds on some instances and fails on the other instances. When the execution state is Success on some instances and is Failed or Stopped on the other instances, the overall execution state is PartialFailed.
Note The value of the InvokeStatus response parameter is similar to that of this parameter, but we recommend that you check this parameter value.
RepeatMode String Once

Indicates the execution mode of the command. Valid values:

  • Once: The command is immediately run.
  • Period: The command is run on a regular basis.
  • NextRebootOnly: The command is automatically run the next time the instance starts.
  • EveryReboot: The command is automatically run every time the instance starts.
CommandId String c-hz0jdfwcsr****

The ID of the command.

CommandType String RunShellScript

The type of the command.

InvokeStatus String Finished

The overall execution state of the command.

Note We recommend that you ignore this parameter and check the value of the InvocationStatus response parameter for the overall execution state.
Parameters String {}

The custom parameters in the command.

Timed Boolean false

Indicates whether the command is to be automatically run.

CommandContent String cnBtIC1xYSB8IGdyZXAgdnNm****

The Base64-encoded command content.

CommandName String CommandTestName

The name of the command.

CommandDescription String testDescription

The description of the command.

InvokeId String t-hz0jdfwd9f****

The ID of the execution.

Username String root

The username that was used to run the command on the instance.

WorkingDir String /home/

The execution path of the command.

Timeout Long 60

The maximum timeout period for the command execution on the instance. Unit: seconds.

When a command cannot be run, the command execution times out. When the execution times out, the command process is forcefully terminated by canceling the PID of the command.

InvokeInstances Array of InvokeInstance

Details about the instances on which the command is run.

InvokeInstance
CreationTime String 2019-12-20T06:15:54Z

The start time of the execution.

UpdateTime String 2020-01-19T09:15:47Z

The time when the execution status was updated.

FinishTime String 2019-12-20T06:15:56Z

The end time of the execution.

InvocationStatus String Success

The execution state on a single instance. Valid values:

  • Pending: The system is verifying or sending the command.
  • Invalid: The specified command type or parameter is invalid.
  • Aborted: The command failed to be sent. To send a command to an instance, make sure that the instance is in the Running state and the command is sent within 1 minute.
  • Running: The command is being run on the instance.
  • Success:
    • One-time execution: The execution is complete, and the exit code is 0.
    • Recurring execution: The previous occurrence of the execution is complete, and the exit code is 0. The specified recurring period during which the command is run ends.
  • Failed:
    • One-time execution: The execution is complete, but the exit code is not 0.
    • Recurring execution: The previous occurrence of the execution is complete, but the exit code is not 0. The specified recurring period during which the command is run is about to end.
  • Error: The execution cannot proceed due to an exception.
  • Timeout: The execution times out.
  • Cancelled: The execution is canceled, and the command is not started.
  • Stopping: The execution is being stopped.
  • Terminated: The command is terminated while it is being run.
  • Scheduled:
    • One-time execution: The overall execution state can never be Scheduled.
    • Recurring execution: The command is waiting to be run.
Repeats Integer 0

The number of times that the command is run on the instance.

  • If the execution is a one-time execution, the value is 0 or 1.
  • If the execution is a recurring execution, the value is the number of times that the command is run.
InstanceId String i-bp1i7gg30r52z2em****

The ID of the instance.

Output String OutPutTestmsg

The output of the command.

Dropped Integer 0

The size of the text that is truncated and discarded when the Output value exceeds 24 KB in size.

StopTime String 2020-01-19T09:15:47Z

The time when the command stopped being run on the instance. If you call the StopInvocation operation to manually stop the execution, the value is the time when you call the operation.

ExitCode Long 0

The exit code of the execution. Valid values:

  • For Linux instances, the exit code is the exit code of the shell process.
  • For Windows instances, the exit code is the exit code of the batch or PowerShell process.
StartTime String 2019-12-20T06:15:55Z

The time when the command started to be run on the instance.

ErrorInfo String the specified instance does not exists

Details about the reason why the command failed to be sent or run. Valid values:

  • If this parameter is empty, the execution is normal.
  • 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
Timed Boolean false

Indicates whether the command is to be automatically run.

ErrorCode String InstanceNotExists

The code that indicates why the command failed to be sent or run. Valid values:

  • If this parameter is empty, the execution is normal.
  • InstanceNotExists: The instance does not exist or has been released.
  • InstanceReleased: The instance was released while the command was being run on the instance.
  • InstanceNotRunning: The instance was not in the Running state while the command started to be run.
  • CommandNotApplicable: The command is not applicable to the specified instance.
  • AccountNotExists: The specified account does not exist.
  • DirectoryNotExists: The specified directory does not exist.
  • BadCronExpression: The specified cron expression for the execution schedule is invalid.
  • ClientNotRunning: The Cloud Assistant client is not running.
  • ClientNotResponse: The Cloud Assistant client is not responding.
  • ClientIsUpgrading: The Cloud Assistant client is being upgraded.
  • ClientNeedUpgrade: The Cloud Assistant client needs to be upgraded.
  • DeliveryTimeout: The request to send the command has timed out.
  • ExecutionTimeout: The execution has timed out.
  • ExecutionException: An exception occurred while the command was being run.
  • ExecutionInterrupted: The execution was interrupted.
  • ExitCodeNonzero: The execution is complete, but the exit code is not 0.
InstanceInvokeStatus String Finished

The execution state on a single instance.

Note We recommend that you ignore this parameter and check the value of the InvocationStatus response parameter for the overall execution state.

Examples

Sample requests

http(s)://ecs.aliyuncs.com/?Action=DescribeInvocations
&RegionId=cn-hangzhou
&InvokeId=t-hz0jdfwd9f****
&CommandId=c-hz0jdfwcsr****
&CommandName=CommandTestName
&CommandType=RunShellScript
&Timed=true
&InvokeStatus=Finished
&InstanceId=i-bp1i7gg30r52z2em****
&PageNumber=1
&PageSize=10
&RepeatMode=Once
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeInvocationsResponse>
    <PageSize>10</PageSize>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
    <PageNumber>1</PageNumber>
    <TotalCount>1</TotalCount>
    <Invocations>
        <Invocation>
            <CreationTime>2020-01-19T09:15:46Z</CreationTime>
            <Frequency>0 */20 * * * *</Frequency>
            <InvocationStatus>Running</InvocationStatus>
            <RepeatMode>Once</RepeatMode>
            <CommandId>c-hz0jdfwcsr****</CommandId>
            <CommandType>RunShellScript</CommandType>
            <InvokeStatus>Finished</InvokeStatus>
            <Parameters>{}</Parameters>
            <Timed>false</Timed>
            <CommandContent>cnBtIC1xYSB8IGdyZXAgdnNm****</CommandContent>
            <CommandName>CommandTestName</CommandName>
            <CommandDescription>testDescription</CommandDescription>
            <InvokeId>t-hz0jdfwd9f****</InvokeId>
            <Username>root</Username>
            <WorkingDir>/home/</WorkingDir>
            <Timeout>60</Timeout>
            <InvokeInstances>
                <InvokeInstance>
                    <CreationTime>2019-12-20T06:15:54Z</CreationTime>
                    <UpdateTime>2020-01-19T09:15:47Z</UpdateTime>
                    <FinishTime>2019-12-20T06:15:56Z</FinishTime>
                    <InvocationStatus>Success</InvocationStatus>
                    <Repeats>0</Repeats>
                    <InstanceId>i-bp1i7gg30r52z2em****</InstanceId>
                    <Output>OutPutTestmsg</Output>
                    <Dropped>0</Dropped>
                    <StopTime>2020-01-19T09:15:47Z</StopTime>
                    <ExitCode>0</ExitCode>
                    <StartTime>2019-12-20T06:15:55Z</StartTime>
                    <ErrorInfo>the specified instance does not exists</ErrorInfo>
                    <Timed>false</Timed>
                    <ErrorCode>InstanceNotExists</ErrorCode>
                    <InstanceInvokeStatus>Finished</InstanceInvokeStatus>
                </InvokeInstance>
            </InvokeInstances>
        </Invocation>
    </Invocations>
</DescribeInvocationsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "PageSize" : 10,
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "PageNumber" : 1,
  "TotalCount" : 1,
  "Invocations" : {
    "Invocation" : [ {
      "CreationTime" : "2020-01-19T09:15:46Z",
      "Frequency" : "0 */20 * * * *",
      "InvocationStatus" : "Running",
      "RepeatMode" : "Once",
      "CommandId" : "c-hz0jdfwcsr****",
      "CommandType" : "RunShellScript",
      "InvokeStatus" : "Finished",
      "Parameters" : "{}",
      "Timed" : false,
      "CommandContent" : "cnBtIC1xYSB8IGdyZXAgdnNm****",
      "CommandName" : "CommandTestName",
      "CommandDescription" : "testDescription",
      "InvokeId" : "t-hz0jdfwd9f****",
      "Username" : "root",
      "WorkingDir" : "/home/",
      "Timeout" : 60,
      "InvokeInstances" : {
        "InvokeInstance" : [ {
          "CreationTime" : "2019-12-20T06:15:54Z",
          "UpdateTime" : "2020-01-19T09:15:47Z",
          "FinishTime" : "2019-12-20T06:15:56Z",
          "InvocationStatus" : "Success",
          "Repeats" : 0,
          "InstanceId" : "i-bp1i7gg30r52z2em****",
          "Output" : "OutPutTestmsg",
          "Dropped" : 0,
          "StopTime" : "2020-01-19T09:15:47Z",
          "ExitCode" : 0,
          "StartTime" : "2019-12-20T06:15:55Z",
          "ErrorInfo" : "the specified instance does not exists",
          "Timed" : false,
          "ErrorCode" : "InstanceNotExists",
          "InstanceInvokeStatus" : "Finished"
        } ]
      }
    } ]
  }
}

Error codes

HTTP status code Error code Error message Description
400 RegionId.ApiNotSupported The api is not supported in this region. The error message returned because the API operation cannot be called in the specified region. Check whether the RegionId parameter is valid.
403 InvalidParam.PageNumber The specified parameter is invalid. The error message returned because the specified PageNumber parameter is invalid.
403 InvalidParam.PageSize The specified parameter is invalid. The error message returned because the specified PageSize parameter is invalid.
403 Operation.Forbidden The operation is not permitted. The error message returned because the operation is not supported.
500 InternalError.Dispatch An error occurred when you dispatched the request. The error message returned because an error occurred while the request was being sent. Try again later.

For a list of error codes, visit the API Error Center.