All Products
Search
Document Center

Elastic Compute Service:ModifyInvocationAttribute

Last Updated:Aug 14, 2026

Modifies the execution information of a Cloud Assistant scheduled task, including the command content, scheduled execution method, and adding ECS instances or managed instances to the task.

Operation description

  • You can modify tasks with the following execution modes (see the RepeatMode value returned by DescribeInvocations):
    • Period: periodic execution.

    • NextRebootOnly: automatically executes the command the next time the instance starts.

    • EveryReboot: automatically executes the command every time the instance starts.

  • You can modify tasks in the following states (see the InvocationStatus value returned by DescribeInvocations):
    • Pending: The system is verifying or sending the command. If the command execution state on at least one instance is Pending, the overall execution state is Pending.

    • Running: The command is running on the instance. If the command execution state on at least one instance is Running, the overall execution state is Running.

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

    • Stopping: The task is being stopped. If the command execution state on at least one instance is Stopping, the overall execution state is Stopping.

  • Before modifying scheduled task execution information (including command content, custom parameters, and execution frequency), the Cloud Assistant Agent version on the ECS instances or managed instances that have already executed the task must be later than the following versions:
    • Linux: 2.2.3.541

    • Windows: 2.1.3.541

    • If the call result returns the InvalidOperation.CloudAssistantVersionUnsupported error code, update the Cloud Assistant Agent to the latest version.

  • When you execute a Cloud Assistant common command, you cannot modify the command content CommandContent.

  • When you modify the command content CommandContent, and the task was created by calling InvokeCommand or RunCommand with KeepCommand set to true, a new command is created for long-term retention, which counts toward your Cloud Assistant command quota. You can retain up to 500 to 50,000 Cloud Assistant commands in a region. You can also request a quota increase. For information about how to query and increase quotas, see Quota management.

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:ModifyInvocationAttribute

update

*Invocation

acs:ecs:{#regionId}:{#accountId}:invocation/{#invocationId}

Instance

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

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

cn-hangzhou

InstanceId

array

No

The instance ID of the ECS instance or managed instance to add to the task.

string

No

The instance ID of the ECS instance or managed instance to add to the task. The total number of instances to add and instances that have already executed the task cannot exceed 100.

i-bp1i7gg30r52z2em****

InvokeId

string

Yes

The command execution ID of the task to modify.

t-hz0jdfwd9f****

CommandContent

string

No

The modified command content. The command content can be plaintext or Base64-encoded. Note the following items:

  • The size of the command content after Base64 encoding cannot exceed 24 KB.

  • If your command content is Base64-encoded, you must set ContentEncoding=Base64.

  • You can enable the custom parameter feature in the command content by specifying EnableParameter=true:

    • Define custom parameters by enclosing them in {{}}. Spaces and line breaks before and after the parameter name within {{}} are ignored.

    • The number of custom parameters cannot exceed 20.

    • Custom parameter names can contain a-zA-Z0-9-_ characters. The acs:: prefix for specifying non-built-in environment parameters is not supported. Other characters are not supported. Parameter names are case-insensitive.

    • A single custom parameter name cannot exceed 64 bytes.

  • You can specify built-in environment parameters as custom parameters. When the command is executed, you do not need to manually assign values to the parameters. Cloud Assistant automatically replaces them with the corresponding values in the environment. The following built-in environment parameters are supported:

    • {{ACS::RegionId}}: The region ID.

    • {{ACS::AccountId}}: The Alibaba Cloud account ID.

    • {{ACS::InstanceId}}: The instance ID. When the command is sent to multiple instances, to specify {{ACS::InstanceId}} as a built-in environment parameter, ensure that the Cloud Assistant Agent version is not earlier than the following versions:
      • Linux: 2.2.3.309

      • Windows: 2.1.3.309

    • {{ACS::InstanceName}}: The instance name. When the command is sent to multiple instances, to specify {{ACS::InstanceName}} as a built-in environment parameter, ensure that the Cloud Assistant Agent version is not earlier than the following versions:
      • Linux: 2.2.3.344

      • Windows: 2.1.3.344

    • {{ACS::InvokeId}}: The command execution ID. To specify {{ACS::InvokeId}} as a built-in environment parameter, ensure that the Cloud Assistant Agent version is not earlier than the following versions:
      • Linux: 2.2.3.309

      • Windows: 2.1.3.309

    • {{ACS::CommandId}}: The command ID. When you call this operation to execute a command, to specify {{ACS::CommandId}} as a built-in environment parameter, ensure that the Cloud Assistant Agent version is not earlier than the following versions:
      • Linux: 2.2.3.309

      • Windows: 2.1.3.309

ZWNobyAxMjM=

EnableParameter

boolean

No

Specifies whether the modified command contains custom parameters.

  • When you enable custom parameters or modify custom parameters Parameters, set this parameter to true.

  • When you do not modify custom parameters Parameters, do not set this parameter or set it to false.

false

Parameters

object

No

The key-value pairs of custom parameters to modify when the command contains custom parameters.

The number of custom parameters ranges from 0 to 10. Note the following items:

  • Keys cannot be empty strings and can contain up to 64 characters.

  • Values can be empty strings.

  • After the custom parameters and original command content are Base64-encoded, the total size of the command content cannot exceed 24 KB.

  • The set of custom parameter names must be a subset of the parameter set defined when the command was created. For parameters that are not passed in, you can use empty strings as substitutes.

Default value: empty, which indicates that no custom parameter key-value pairs are modified.

{"name":"Jack", "accessKey":"LTAI*************"}

Frequency

string

No

The modified scheduled execution frequency. This parameter takes effect only when RepeatMode is set to Period. Three types of scheduled execution are supported: fixed interval execution (based on Rate expressions), one-time execution at a specified time, and clock-based scheduled execution (based on Cron expressions).

  • Fixed interval execution: Based on Rate expressions, the command is executed at the specified time interval. The time interval can be specified in seconds (s), minutes (m), hours (h), or days (d). This is applicable to scenarios where tasks are executed at fixed intervals. Format: rate(<interval value><interval unit>). For example, to execute every 5 minutes, use rate(5m). Fixed interval execution has the following limits:

    • The time interval cannot exceed 7 days or be less than 60 seconds, and must be greater than the timeout period specified when the scheduled task was created.

    • The execution interval is based only on the fixed frequency and is not related to the actual time required for task execution. For example, if the command is set to execute every 5 minutes and the task takes 2 minutes to complete, the next round of execution starts 3 minutes after the task is completed.

    • The next execution time is calculated based on the task creation time (see CreationTime returned by DescribeInvocations, note that this is not the modification time) and the modified execution interval.

  • One-time execution at a specified time: The command is executed once at the specified time zone and time point. Format: at(yyyy-MM-dd HH:mm:ss <time zone>), which is at(year-month-day hour:minute:second <time zone>). If no time zone is specified, the default is UTC. The time zone supports the following three formats:

    • Full time zone name: such as Asia/Shanghai (China/Shanghai time) or America/Los_Angeles (US/Los Angeles time).

    • Time zone offset from Greenwich Mean Time: such as GMT+8:00 (East 8th time zone) or GMT-7:00 (West 7th time zone). When using GMT format, leading zeros are not supported for the hour value.

    • Time zone abbreviation: Only UTC (Coordinated Universal Time) is supported.

    For example, to execute once at 13:15:30 on June 6, 2022 in China/Shanghai time, use: at(2022-06-06 13:15:30 Asia/Shanghai). To execute once at 13:15:30 on June 6, 2022 in the West 7th time zone, use: at(2022-06-06 13:15:30 GMT-7:00).

  • Clock-based scheduled execution (based on Cron expressions): Based on Cron expressions, the command is executed according to the scheduled task settings. Format: <seconds> <minutes> <hours> <day of month> <month> <day of week> <year (optional)> <time zone>, which is <Cron expression> <time zone>. The scheduled task execution time is calculated based on the Cron expression in the specified time zone. If no time zone is specified, the default is the internal system time zone of the instance executing the scheduled task. For more information about Cron expressions, see Cron expressions. The time zone supports the following three formats:

    • Full time zone name: such as Asia/Shanghai (China/Shanghai time) or America/Los_Angeles (US/Los Angeles time).

    • Time zone offset from Greenwich Mean Time: such as GMT+8:00 (East 8th time zone) or GMT-7:00 (West 7th time zone). When using GMT format, leading zeros are not supported for the hour value.

    • Time zone abbreviation: Only UTC (Coordinated Universal Time) is supported. For example, to execute once every day at 10:15 AM in China/Shanghai time in 2022, use 0 15 10 ? * * 2022 Asia/Shanghai. To execute every half hour from 10:00 AM to 11:30 AM every day in 2022 in the East 8th time zone, use 0 0/30 10-11 * * ? 2022 GMT+8:00. To execute every 5 minutes from 2:00 PM to 2:55 PM every day in October every two years starting from 2022 in UTC, use 0 0/5 14 * 10 ? 2022/2 UTC.

    Note

    The minimum time interval must be greater than or equal to the timeout period specified when the scheduled task was created, and must not be less than 10 seconds.

0 */20 * * * *

ContentEncoding

string

No

The encoding method of the command content (CommandContent). Valid values (case-insensitive):

  • PlainText: no encoding. The content is transmitted in plaintext.

  • Base64: Base64 encoding.

Default value: PlainText. If an invalid value is specified, it is treated as PlainText.

PlainText

ClientToken

string

No

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but make sure that the token is unique among different requests. The ClientToken value can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-426655440000

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

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

CommandId

string

The command ID.

  • A new command is created and the new CommandId is returned only when CommandContent is changed.

  • When CommandContent is not changed, no new command is created, and the CommandId of the currently executing command is returned.

  • If you called InvokeCommand, or called RunCommand with KeepCommand set to true, the new command is retained. Otherwise, when the execution is completed or the task is manually stopped, all commands associated with the task are deleted.

c-hz01272yr52****

Examples

Success response

JSON format

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "CommandId": "c-hz01272yr52****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter.Frequency The specified parameter Frequency is not valid. The specified parameter Frequency is illegal.
400 InvalidParameters.KeyDuplicate The key in the parameter Parameters cannot be duplicated. Keys in parameter Parameters cannot be duplicated.
400 InvalidParameters.KeyNotMatch The key in the parameter Parameters do not match those defined when creating the command. The key in the parameter Parameters does not match the one defined when the command was created.
400 InvalidParameters.KeyMalformed The key in the parameter Parameters is not valid. A key in the Parameters parameter is invalid.
400 InvalidParameters.KeyEmpty The key in the parameter Parameters cannot be empty. The key in the parameter Parameters cannot be empty.
400 InvalidCommandContent.DecodeError The specified parameter CommandContent can not be Base64 decoded. Parameter CommandContent cannot be Base64 decoded.
400 InvalidClientToken.Malformed The specified parameter clientToken is not valid. The specified ClientToken parameter does not meet the format requirements. The parameter must contain only ASCII characters and cannot exceed 64 characters in length.
500 InternalError An error occurred when you dispatched the request. An error occurred while sending the request, please try again later.
403 InvalidInstanceId.OSTypeUnsupported The OS type of the instance corresponding to the parameter InstanceId does not support the specified command type. The operating system type of the instance specified by InstanceId does not support this operation.
403 InvalidOperation.RepeatModeUnsupported The operation is not supported for current repeat mode of invocation. The current command execution method does not support this operation.
403 InvalidOperation.InvokeAlreadyFinished The operation is not supported for finished invocation. The operation is not supported for completed tasks.
403 InvalidOperation.CloudAssistantVersionUnsupported The operation is not supported for current CloudAssistant version of instance. The Cloud Assistant version on the current instance does not support this operation.
403 InvalidOperation.ModifyPublicCommandUnsupported Modification of the content of Public Command is not supported. Modifying the contents of public commands is not supported.
403 InvalidCommandContent.LengthLimitExceeded The length of the parameter CommandContent exceeds the limit of %s KB characters.
403 Operation.Forbidden The operation is not permitted. The operation is not supported.
403 InvalidParameters.CountLimitExceeded The count of the parameter Parameters exceeds the limit of 10. The number of parameter Parameters exceeds the limit of 10.
403 InvalidParameters.KeyLengthLimitExceeded The length of the key in the parameter Parameters exceeds the limit of 64 characters. The length of a key in the Parameters parameter exceeds the limit of 64 characters.
403 InvalidInstanceId.CountLimitExceeded The count of the parameter InstanceId exceeds the limit of %s.
403 CommandLimitExceeded The count of command in current region exceeds the limit of %s.
403 InvalidParameters.ValueTypeUnsupported The type of the value in the parameter Parameters is not supported. The type of the value Parameters the parameter is not supported.
403 IdempotentParameterMismatch The specified parameter has changed while using an already used clientToken. The specified client token has already been used.
403 IdempotentProcessing The previous idempotent request(s) is still processing. A previous idempotent request is being processed. Try again later.
404 InvalidInvokeId.NotFound The specified parameter InvokeId does not exist. The specified command execution ID does not exist.
404 InvalidInstanceId.NotFound The specified parameter InstanceId does not exist. The specified instance ID does not exist.
404 InvalidRegionId.NotFound The specified parameter RegionId does not exist. The region information is invalid.
404 InvalidCommandId.NotFound The specified CommandId does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.