Create reusable Cloud Assistant commands to automate O&M tasks on ECS instances without logging in.
Supported command types:
| OS | Supported types |
|---|---|
| Linux | Shell, Python, Perl |
| Windows | Bat, PowerShell |
Limitations
| Resource | Limit |
|---|---|
| Commands per region | 500–50,000 (quota per account; may increase with ECS usage) |
| Max Base64-encoded script size | 18 KB |
| Custom parameters per command | 20 |
To view or increase your quota, see Manage quotas. Include a detailed reason in your request to improve approval chances.
Prerequisites
Ensure the following:
-
An Alibaba Cloud account with ECS access.
-
(Optional) A resource group for managing command permissions at the resource group level with RAM.
Create a command in the ECS console
Do not include sensitive information — such as AccessKey pairs, passwords, or authorization codes — as plaintext in commands. Use custom parameters in {{key}} format and supply values at runtime.
-
Go to the ECS Cloud Assistant page.
-
In the top navigation bar, select a region and resource group.
Resource groups let you manage command permissions with RAM policies. See Cloud Assistant command-specific sample custom policies and Classify resources into resource groups and grant permissions on the resource groups.

-
On the ECS Cloud Assistant page, click Create/Run Command.
-
In the Command Information section, configure the command. Command type Select the type that matches your target instance OS. Command content Enter or paste the command. Verify the syntax, logic, and algorithm before saving. Example — archive a file to
/backupon a Linux instance:-
Run at Fixed Interval: Set an interval (60 seconds–7 days) using a rate expression. The interval is the gap between consecutive executions, not the execution duration. For example, a 5-minute interval with a 2-minute run means the next run starts 3 minutes after the previous run ends. The first run starts after the interval elapses from task creation. > Note: The interval must exceed the command's timeout period.
-
Run Only Once at Specified Time: Set a date, time, and time zone. Example: May 17, 2022, 17:30:50 with (GMT+08:00) Asia/Shanghai.
-
Run on Clock-based Schedule Cron Expression: Specify a cron expression (accurate to seconds) and a time zone. Minimum interval: 10 seconds (must exceed the timeout period). Example:
0 0 12 ? * WED 2022with (GMT+08:00) Asia/Shanghai runs every Wednesday at 12:00:00 in 2022. See Cron expressions.
Version requirements: - `{{ACS::InstanceId}}` and `{{ACS::InstanceName}}`: Each target instance must run the minimum Cloud Assistant Agent version listed above. - `{{ACS::InvokeId}}`: Requires the minimum Agent version listed above. - `{{ACS::CommandId}}`: When calling RunCommand, requires the minimum Agent version listed above. To upgrade, see Install Cloud Assistant Agent.
Command source
Option Description Enter Command Content Write a new command. Select Saved Command Use an existing saved command. Parameter Description Minimum Cloud Assistant Agent version {{ACS::RegionId}}Region ID — {{ACS::AccountId}}Alibaba Cloud account UID — {{ACS::InstanceId}}Instance ID Linux >= 2.2.3.309, Windows >= 2.1.3.309 {{ACS::InstanceName}}Instance name Linux >= 2.2.3.344, Windows >= 2.1.3.344 {{ACS::InvokeId}}Command task ID Linux >= 2.2.3.309, Windows >= 2.1.3.309 {{ACS::CommandId}}Command ID Linux >= 2.2.3.309, Windows >= 2.1.3.309 Execution plan
Option Behavior Immediate execution Runs when you click Run or Run and Save. After the next startup of the system Runs the next time associated instances start. After each system startup Runs every time associated instances start. Run on Schedule Runs on a defined schedule. See options below. Other parameters
Parameter Description Command Name A name for the command. Command Description A description of the command purpose. Username The OS user that runs the command. Default: root(Linux),system(Windows). Use the minimum required privileges. See Run Cloud Assistant commands as a regular user.Execution Path The working directory. Default: /home(Linux),C:\Windows\system32(Windows).Timeout Maximum execution time in seconds. Default: 60. Minimum: 10 (values below 10 are set to 10). Tag A key-value pair for classification. Run and Save applies the tag to both the command and the execution task. Run applies it to the command only. #!/bin/bash OF=/backup/my-backup-$(date +%Y%m%d).tgz tar -cf $OF {{file}}{{file}}is a custom parameter. Set it at runtime (for example,/app/usrcredential). See View the system configurations of ECS instances. Use parameters Turn on Use Parameters to define custom parameters in the{{key}}format. Up to 20 custom parameters per command. Cloud Assistant also provides built-in environment parameters resolved at runtime: Run on Schedule options: -
-
In Select Instance and Select Managed Instances, select target instances.
A managed instance is a non-ECS server managed by Cloud Assistant. See Alibaba Cloud managed instances.
-
Click Save.
Create a command using Alibaba Cloud CLI
Call CreateCommand to create a command. The following example creates a command named update that updates the OS on Linux instances.
aliyun ecs CreateCommand --RegionId 'cn-hangzhou' \
--CommandContent 'eXVtIHVwZGF0ZSAteQ==' \
--Type 'RunShellScript' \
--Name 'update' \
--Description 'update' \
--output cols=CommandId
Replace the values in single quotes with your actual values.
Key parameters:
| Parameter | Example | Description |
|---|---|---|
RegionId |
cn-hangzhou |
The region. |
Name |
update |
The command name. |
Type |
RunShellScript |
The command type: RunShellScript (Linux Shell), RunBatScript (Windows Bat), or RunPowerShellScript (Windows PowerShell). |
CommandContent |
eXVtIHVwZGF0ZSAteQ== |
The Base64-encoded command content. |
Description |
update |
The command description. |
For the full parameter reference, see CreateCommand.
Sample response:
CommandId
---------
c-hz018qng4on****
Next steps
After creating a command, view it on the My Commands tab. To run it on specific instances, see Run a command.
If you enabled Use Parameters, enter parameter values in Command Parameters when running the command.