You can use Cloud Assistant commands to perform routine tasks on ECS instances. These tasks include running automated O&M scripts, polling processes, resetting user passwords, installing or uninstalling software, updating applications, and installing patches. Command types can be batch or PowerShell for Windows instances, and shell for Linux instances. You can specify custom parameters as variables in Cloud Assistant commands.
Background information
- You can retain a maximum of 100 Cloud Assistant commands within each Alibaba Cloud
region. This quota may increase based on your ECS usage.
Note You can also call the DescribeAccountAttributes operation with AttributeName.N set to max-axt-command-count to query the maximum number of Cloud Assistant commands that you can retain within a region.
- A command cannot exceed 16 KB in size after it is encoded in Base64.
- A maximum of 20 custom parameters can be specified in a Cloud Assistant command.
- When you create a command, you must check whether the syntax, logic, and algorithm
of the command are correct.
For example, assume that you have created the /backup directory (
mkdir /backup
) on an instance, you can run the following shell commands to archive a file in this directory:#! /bin/bash OF=/backup/my-backup-$(date +%Y%m%d).tgz tar -cf $OF {{file}}
Note In this example,{{file}}
is a custom parameter. When you run the commands, you can set this custom parameter to the name of the file to be archived. Example: /app/usrcredential. Custom parameters can be used in scenarios of dynamic values and multi-purpose values. We recommend that you specify custom parameters for security-sensitive data or data that changes based on the environment. Such data includes AccessKey pairs, instance IDs, authorization codes, time parameters, and critical system files.
Procedure in the console
Procedure by using Alibaba Cloud CLI
- Sample request:
Call the CreateCommand operation to create a Cloud Assistant command named test. The command content is
echo 123
and is encoded in Base64 as plaintext. For Windows instances, set Type to RunBatScript or RunPowershellScript.aliyun ecs CreateCommand --RegionId TheRegionId --CommandContent ZWNobyAxMjM= --Type RunShellScript --Name test --Description test --output cols=CommandId
- Sample response:
CommandId --------- c-hz0b8osxk8a***