All Products
Search
Document Center

Elastic Compute Service:DescribeInvocations

Last Updated:Jun 24, 2026

Queries the execution list and status of Cloud Assistant commands.

Operation description

  • After you run a command, it does not necessarily run successfully or produce the expected results. You must check the actual execution results based on the return values of this operation.

  • You can query execution information from the last 30 days. A maximum of 10,000 execution records are retained.

  • You can subscribe to Cloud Assistant task status events to obtain task results through events, which avoids frequent polling and improves efficiency.

  • When paged query the first page of results, set only MaxResults to limit the number of entries returned. The NextToken value in the response serves as the token for querying subsequent pages. When paged query subsequent pages, set NextToken to the value obtained from the previous response and set MaxResults to limit the number of entries returned.

  • Differences between DescribeInvocations and DescribeInvocationResults:

    • When a single RunCommand/InvokeCommand call specifies multiple instances:
      • DescribeInvocations returns the execution status on each instance and the aggregated status across multiple instances.

      • DescribeInvocationResults returns only the individual execution status on each instance, without the aggregated status across multiple instances.

    • When a single RunCommand/InvokeCommand call specifies one instance:
      • DescribeInvocations and DescribeInvocationResults are largely interchangeable.

    • When you want to view the execution history of scheduled (periodic) tasks or tasks that run automatically at instance startup (RepeatMode=Period, EveryReboot), only DescribeInvocationResults can return historical execution records (you must specify IncludeHistory=true). DescribeInvocations returns only the latest task status.

    • When you want to view the command content and parameters, only DescribeInvocations returns CommandContent.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:DescribeInvocations

get

Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

Command

acs:ecs:{#regionId}:{#accountId}:command/{#commandId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID. You can call DescribeRegions to query the most recent region list.

cn-hangzhou

ResourceGroupId

string

No

The resource group ID for command execution. After you specify this parameter, you must also specify ResourceGroupId when running the command. This parameter filters the corresponding command execution results.

rg-bp67acfmxazb4p****

RegionId

string

Yes

地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

cn-hangzhou

InvokeId

string

No

The command execution ID.

t-hz0jdfwd9f****

CommandId

string

No

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

c-hz0jdfwcsr****

CommandName

string

No

The command name. This parameter does not take effect if you also specify InstanceId.

CommandTestName

CommandType

string

No

The command type. Valid values:

  • RunBatScript: Bat script that runs on Windows instances.

  • RunPowerShellScript: PowerShell script that runs on Windows instances.

  • RunShellScript: Shell script that runs on Linux instances.

RunShellScript

Timed

boolean

No

Specifies whether the command will be automatically run in the future. Valid values:

  • true: Queries commands for which the RepeatMode parameter is set to Period, NextRebootOnly, or EveryReboot when RunCommand or InvokeCommand is called.

  • false: Queries commands in the following two states:
    • Commands for which the RepeatMode parameter is set to Once when RunCommand or InvokeCommand is called.

    • Commands that have been canceled, stopped, or completed.

Default value: false.

true

InvokeStatus

string

No

The overall execution status of the command. The overall execution status depends on the common execution status across one or more instances in the execution. Valid values:

  • Running:
    • Scheduled execution: The execution status remains Running until you manually stop the scheduled command.

    • One-time execution: The overall execution status is Running as long as the command process is running on any instance.

  • Finished:
    • Scheduled execution: The command process never reaches the Finished state.

    • One-time execution: All instances have completed execution, or the command process on some instances was manually stopped while the remaining instances completed execution.

  • Success: The command execution status on each instance is Stopped or Success, and the command execution status on at least one instance is Success.
    • Immediate task: The command execution is complete and the exit code is 0.

    • Scheduled task: The last execution was successful with an exit code of 0, and all specified execution times have elapsed.

  • Failed:
    • Scheduled execution: The command process never reaches the Failed state.

    • One-time execution: All instances failed to run the command.

  • Stopped: The command was stopped.

  • Stopping: The command is being stopped.

  • PartialFailed: The command partially failed. This value does not take effect if you also specify InstanceId.

  • Pending: The system is verifying or sending the command. The overall execution status is Pending if the command execution status on at least one instance is Pending.

  • Scheduled: The scheduled command has been sent and is waiting to run. The overall execution status is Scheduled if the command execution status on at least one instance is Scheduled.

Finished

InstanceId

string

No

The instance ID. If you specify this parameter, all command execution records for the instance are queried.

i-bp1i7gg30r52z2em****

ContentEncoding

string

No

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

  • PlainText: Returns the original command content and output.

  • Base64: Returns the Base64-encoded command content and output.

Default value: Base64.

PlainText

IncludeOutput

boolean

No

Specifies whether to return the command output in the results.

  • true: The command output is returned. You must specify at least InvokeId or InstanceId.

  • false: The command output is not returned.

Default value: false.

false

PageNumber

integer

No

Note

This parameter is about to be deprecated. Use NextToken and MaxResults to perform paging queries.

1

PageSize

integer

No

Note

This parameter is about to be deprecated. Use NextToken and MaxResults to perform paging queries.

10

MaxResults

integer

No

The maximum number of entries per page for a paged query.

Maximum value: 50.

Default value: 10.

10

NextToken

string

No

The pagination token. Set this parameter to the NextToken value returned in the previous API call.

AAAAAdDWBF2

RepeatMode

string

No

The execution mode of the command. This parameter does not take effect if you also specify InstanceId. Valid values:

  • Once: The command is immediately run.

  • Period: The command is run on a schedule.

  • NextRebootOnly: The command is automatically run the next time the instance starts.

  • EveryReboot: The command is automatically run every time the instance starts.

Default value: empty, which indicates that all execution modes are queried.

Once

Tag

array<object>

No

The tags.

object

No

The tags.

Value

string

No

The tag value of the command execution. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain http:// or https://.

TestValue

Key

string

No

The tag key of the command execution. Valid values of N: 1 to 20. The tag key cannot be an empty string.

If you use a single tag to filter resources, the number of resources with the specified tag cannot exceed 1,000. If you use multiple tags to filter resources, the number of resources with all specified tags attached cannot exceed 1,000. If the resource count exceeds 1,000, call ListTagResources to execute the query.

The tag key can be up to 64 characters in length and cannot start with aliyun or acs:, or contain http:// or https://.

TestKey

Response elements

Element

Type

Description

Example

object

PageSize

integer

The number of entries per page.

10

RequestId

string

The request ID.

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

PageNumber

integer

The page number of the query results.

1

TotalCount

integer

The total number of commands.

1

NextToken

string

The pagination token returned in this call.

AAAAAdDWBF2

Invocations

object

Invocation

array<object>

The command execution records.

array<object>

The time when the task was created.

OssOutputDelivery

string

OSS delivery configuration for command execution output.

oss://testBucket/testPrefix

InvocationStatus

string

The overall execution status of the command. This overall status is determined by the combined execution statuses of all instances involved in this invocation. Possible values are as follows:

  • Pending: The system is validating or sending the command. If at least one instance has a command execution status of Pending, the overall status is Pending.

  • Scheduled: The scheduled command has been sent and is waiting to run. If at least one instance has a command execution status of Scheduled, the overall status is Scheduled.

  • Running: The command is running on an instance. If at least one instance has a command execution status of Running, the overall status is Running.

  • Success: All instances have a command execution status of either Stopped or Success, and at least one instance has a status of Success. In this case, the overall status is Success.

    • For immediately executed jobs: The command completed successfully with an exit code of 0.

    • For scheduled jobs: The most recent execution succeeded with an exit code of 0, and all specified scheduled times have been completed.

  • Failed: All instances have a command execution status of either Stopped or Failed. The overall status is Failed if any instance has one or more of the following statuses:

    • Command validation failed (Invalid).

    • Failed to send the command (Aborted).

    • Command execution completed but with a non-zero exit code (Failed).

    • Command execution timed out (Timeout).

    • Command execution encountered an error (Error).

  • Stopping: The job is being stopped. If at least one instance has a command execution status of Stopping, the overall status is Stopping.

  • Stopped: The job has been stopped. If all instances have a command execution status of Stopped, the overall status is Stopped. The following instance statuses result in a Stopped overall status:

    • The job was canceled (Cancelled).

    • The job was terminated (Terminated).

  • PartialFailed: Some instances succeeded while others failed. If all instances have a command execution status of Success, Failed, or Stopped, and there is a mix of success and failure, the overall status is PartialFailed.

Note

The InvokeStatus parameter in the response has a similar meaning to this parameter, but we recommend that you refer to this return value.

Running

Parameters

string

Custom parameters in the command.

{}

Timed

boolean

Indicates whether the queried command will be automatically executed in the future.

false

CommandDescription

string

Command description.

testDescription

Timeout

integer

The maximum timeout duration, in seconds, for the command you created when it is executed on an ECS instance.

A timeout occurs when the command you created cannot be run for any reason. After the timeout, the command process is forcibly stopped, meaning the command's PID is canceled.

60

InvokeInstances

object

InvokeInstance

array<object>

The type of the target instance set for execution.

object

The list of execution statuses.

Dropped

integer

The length of text truncated and discarded from the Output field when it exceeds 24 KB.

0

InvocationStatus

string

The command execution status on a single instance. Possible values:

  • Pending: The system is validating or sending the command.

  • Invalid: The specified command type or parameter is incorrect.

  • Aborted: Failed to send the command to the instance. The instance must be running, and the command must be sent successfully within 1 minute.

  • Running: The command is running on the instance.

  • Success:

    • For one-time execution commands: The command has completed with an exit code of 0.

    • For scheduled commands: The last run succeeded with an exit code of 0, and the scheduled time period has ended.

  • Failed:

    • For one-time execution commands: The command has completed with a non-zero exit code.

    • For scheduled commands: The last run completed with a non-zero exit code, and the scheduled time period will be aborted.

  • Error: An abnormal condition occurred during command execution, preventing further progress.

  • Timeout: Command execution timed out.

  • Cancelled: The command execution action was canceled before it started.

  • Stopping: The job is being stopped.

  • Terminated: The command was terminated during runtime.

  • Scheduled:

    • For one-time execution commands: Not applicable; this status will not appear.

    • For scheduled commands: Waiting to run.

Success

InstanceId

string

Instance ID.

i-bp1i7gg30r52z2em****

Timed

boolean

Indicates whether the queried command will be automatically executed in the future.

false

InstanceInvokeStatus

string

The command execution progress status on a single instance.

Note

We do not recommend that you view this return value. We recommend that you view the return value of InvocationStatus.

Finished

ExitCode

integer

The exit code of the command process. Possible values:

  • For Linux instances, this is the exit code of the Shell process.

  • For Windows instances, this is the exit code of the Bat or PowerShell process.

0

ErrorInfo

string

Details about why the command failed to be sent or executed. Possible values:

  • empty: The command ran normally.

  • The security group rules denied access to the aliyun service: The security group rule denied access to the Cloud Assistant service.

  • The specified instance does not exist: The specified instance does not exist or has been released.

  • The specified instance was released during task execution: The instance was released while the command was being executed.

  • The specified instance was not running during task execution: The instance was not in the running state when command execution started.

  • The OS type of the instance does not support the specified command type: The command is not applicable to the specified instance.

  • The specified account does not exist: The specified Account does not exist.

  • The specified directory does not exist: The specified folder does not exist.

  • The cron expression is invalid: The specified running time expression is invalid.

  • The aliyun service is not running on the instance: The Cloud Assistant Agent is not running.

  • The aliyun service in the instance does not response: The Cloud Assistant Agent is unresponsive.

  • The aliyun service in the instance is upgrading during task execution: The Cloud Assistant Agent is upgrading.

  • The aliyun service in the instance need to be upgraded to at least version to support the feature: The Cloud Assistant Agent needs to be upgraded. is the minimum version number that supports the feature, and is the specific attribute.

  • The command delivery has been timeout: Sending the command timed out.

  • The command execution has been timeout: Command execution timed out.

  • The command execution got an exception: An exception occurred during command execution.

  • The command execution exit code is not zero: Command execution ended with a non-zero exit code.

  • The specified instance was released during task execution: The instance was released while the file was being sent.

the specified instance does not exists

StartTime

string

The time when the command started executing on the instance.

2019-12-20T06:15:55Z

Repeats

integer

The number of times the command was executed on this instance.

  • If the execution mode is one-time execution, the value is 0 or 1.

  • If the execution mode is scheduled execution, the value indicates how many times the command has been executed.

0

OssOutputUri

string

The URI of the file in OSS to which the command Outputs are delivered. This field is an empty string if delivery is in progress or has failed.

oss://testBucket/testPrefix/output.txt

OssOutputStatus

string

The delivery status of the command Outputs. Valid values:

  • InProgress: Delivery is in progress.

  • Finished: Delivery is complete.

  • Failed: Delivery failed.

Finished

OssOutputErrorCode

string

The error code returned when delivery fails. This value is returned only when OssOutputStatus is Failed.
Valid values:

  • CloudAssistant.UnsupportedInvocationStatus: The job status does not support delivery.

  • CloudAssistant.ClientNeedUpgrade: The Cloud Assistant version does not support delivery. For Linux instances, the Cloud Assistant version must be later than 2.2.4.1007. For Windows instances, the Cloud Assistant version must be later than 2.1.4.1007.

  • OSS.AccessDenied: The user does not have access permissions to the specified bucket.

  • OSS.NoSuchBucket: The specified bucket does not exist.

  • OSS.FileImmutable: The data in the bucket is in a protection status.

  • OSS.InvalidObjectName: The object name is invalid. This includes cases where no object name is specified, the object name exceeds the length limit, or the specified object name is invalid.

CloudAssistant.UnsupportedInvocationStatus

OssOutputErrorInfo

string

Error Details when delivery fails. Returned only when OssOutputStatus is Failed.

The invocation status does not support output delivery.

FinishTime

string

The end time of the command process.

2019-12-20T06:15:56Z

Output

string

The output information of the command.

  • If ContentEncoding is specified as PlainText, the original output information is returned.

  • If ContentEncoding is specified as Base64, the Base64-encoded output information is returned.

OutPutTestmsg

CreationTime

string

The start time of command execution.

2019-12-20T06:15:54Z

UpdateTime

string

The update time of the command status.

2020-01-19T09:15:47Z

ErrorCode

string

The error code indicating why the command failed to be delivered or executed. Possible values:

  • empty: The command ran normally.

  • InstanceNotExists: The specified instance does not exist or has been released.

  • InstanceReleased: The instance was released during command execution.

  • InstanceNotRunning: The instance was not running when command execution started.

  • CommandNotApplicable: The command is not applicable to the specified instance.

  • AccountNotExists: The username specified for command execution does not exist.

  • DirectoryNotExists: The specified folder does not exist.

  • BadCronExpression: The specified execution time expression is invalid.

  • ClientNotRunning: The Cloud Assistant Agent is not running.

  • ClientNotResponse: The Cloud Assistant Agent did not respond.

  • ClientIsUpgrading: The Cloud Assistant Agent is being upgraded.

  • ClientNeedUpgrade: The Cloud Assistant Agent needs to be upgraded.

  • DeliveryTimeout: Command delivery timed out.

  • ExecutionTimeout: Command execution timed out.

  • ExecutionException: An exception occurred during command execution.

  • ExecutionInterrupted: The command execution job was interrupted.

  • ExitCodeNonzero: Command execution finished with a non-zero exit code.

  • SecurityGroupRuleDenied: The security group rule denied access to the Cloud Assistant service.

  • TaskConcurrencyLimit: The number of concurrently executed jobs exceeded the maximum limit.

InstanceNotExists

StopTime

string

If StopInvocation was invoked to stop command execution, this indicates the time when the invocation occurred.

2020-01-19T09:15:47Z

CommandContent

string

Command content.

  • If ContentEncoding is specified as PlainText, the original script content is returned.

  • If ContentEncoding is specified as Base64, the Base64-encoded script content is returned.

cnBtIC1xYSB8IGdyZXAgdnNm****

WorkingDir

string

The path where the command is executed.

/home/

RepeatMode

string

The mode in which the command is executed. Possible values:

  • Once: Execute the command immediately.

  • Period: Execute the command on a schedule.

  • NextRebootOnly: Automatically execute the command the next time the instance starts.

  • EveryReboot: Automatically execute the command every time the instance starts.

  • DryRun: Perform a dry run of this request. The command will not actually be executed. Checks include request parameters, the instance execution environment, and the Cloud Assistant Agent status.

Once

InvokeStatus

string

The overall execution status of the command.

Note

We do not recommend checking this return value. We recommend that you check the return value of InvocationStatus instead.

Finished

CommandType

string

The command type.

RunShellScript

Username

string

The username used to execute the command on the ECS instance.

test

ContainerId

string

The container ID.

ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****

ContainerName

string

The container name.

test-container

CreationTime

string

The Creation Time of the Job.

2020-01-19T09:15:46Z

Frequency

string

The running time of the scheduled command.

0 */20 * * * *

Launcher

string

The launcher for script execution. The length cannot exceed 1 KB.

python3 -u {{ACS::ScriptFileName|Ext(".py")}}

CommandId

string

The command ID.

c-hz0jdfwcsr****

CommandName

string

The command Name.

CommandTestName

InvokeId

string

The command execution ID.

t-hz0jdfwd9f****

TerminationMode

string

The mode used when stopping a Job (either manually or due to a timeout interruption). Possible values:

  • Process: Stops the current script process.

  • ProcessTree: Stops the entire process tree (the script process and the collection of all child processes it created).

ProcessTree

Tags

object

Tag

array<object>

The tag information of the command execution.

object

The tag information of the command execution.

TagKey

string

The tag key of the command execution.

owner

TagValue

string

The tag value of the command execution.

zhangsan

Examples

Success response

JSON format

{
  "PageSize": 10,
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "PageNumber": 1,
  "TotalCount": 1,
  "NextToken": "AAAAAdDWBF2",
  "Invocations": {
    "Invocation": [
      {
        "OssOutputDelivery": "oss://testBucket/testPrefix",
        "InvocationStatus": "Running",
        "Parameters": "{}",
        "Timed": false,
        "CommandDescription": "testDescription",
        "Timeout": 60,
        "InvokeInstances": {
          "InvokeInstance": [
            {
              "Dropped": 0,
              "InvocationStatus": "Success",
              "InstanceId": "i-bp1i7gg30r52z2em****",
              "Timed": false,
              "InstanceInvokeStatus": "Finished",
              "ExitCode": 0,
              "ErrorInfo": "the specified instance does not exists",
              "StartTime": "2019-12-20T06:15:55Z",
              "Repeats": 0,
              "OssOutputUri": "oss://testBucket/testPrefix/output.txt",
              "OssOutputStatus": "Finished",
              "OssOutputErrorCode": "CloudAssistant.UnsupportedInvocationStatus",
              "OssOutputErrorInfo": "The invocation status does not support output delivery.",
              "FinishTime": "2019-12-20T06:15:56Z",
              "Output": "OutPutTestmsg",
              "CreationTime": "2019-12-20T06:15:54Z",
              "UpdateTime": "2020-01-19T09:15:47Z",
              "ErrorCode": "InstanceNotExists",
              "StopTime": "2020-01-19T09:15:47Z"
            }
          ]
        },
        "CommandContent": "cnBtIC1xYSB8IGdyZXAgdnNm****",
        "WorkingDir": "/home/",
        "RepeatMode": "Once",
        "InvokeStatus": "Finished",
        "CommandType": "RunShellScript",
        "Username": "test",
        "ContainerId": "ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****",
        "ContainerName": "test-container",
        "CreationTime": "2020-01-19T09:15:46Z",
        "Frequency": "0 */20 * * * *",
        "Launcher": "python3 -u {{ACS::ScriptFileName|Ext(\".py\")}}",
        "CommandId": "c-hz0jdfwcsr****",
        "CommandName": "CommandTestName",
        "InvokeId": "t-hz0jdfwd9f****",
        "TerminationMode": "ProcessTree",
        "Tags": {
          "Tag": [
            {
              "TagKey": "owner",
              "TagValue": "zhangsan"
            }
          ]
        }
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 RegionId.ApiNotSupported The api is not supported in this region. The API operation cannot be called in the specified region. Check whether the specified RegionId parameter is valid.
400 NumberExceed.Tags The Tags parameter number is exceed. The number of tags exceeds the maximum limit.
400 Duplicate.TagKey The Tag.N.Key contain duplicate key. The specified tag key already exists. Tag keys must be unique.
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. The specified Tag.N.Key parameter is invalid.
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. The specified tag value is invalid.
400 MissingParameter.TagKey You must specify Tag.N.Key. The tag key is not specified.
400 InvalidParam.PageNumber The specified parameter is invalid.
400 InvalidParam.PageSize The specified parameter is invalid.
400 InvalidParameter.NextToken The specified parameter NextToken is not valid. The specified parameter NextToken is illegal.
400 InvalidParameter.MaxResults The specified parameter MaxResults is not valid. The specified parameter MaxResults is illegal.
500 InternalError.Dispatch An error occurred when you dispatched the request. An error occurred while the request is being sent. Try again later.
403 Operation.Forbidden The operation is not permitted. The operation is not supported.
404 InvalidRegionId.NotFound The RegionId provided does not exist in our records. Region information error

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.