Common commands are predefined Cloud Assistant commands from Alibaba Cloud for various scenarios, such as software installation, instance diagnosis, and key rotation. This topic describes how to view and run common commands.
Background
Created and maintained by Alibaba Cloud, common commands automate complex tasks such as server configuration, health checks, software installation, and system patching. They also include Cloud Assistant plug-ins, which are packages that contain scripts or executable programs.
Alibaba Cloud manages the content, publication, and updates for all common commands. You can view the command details, run them on your ECS instances, and track the execution results. For example, you can upgrade the Cloud Assistant Agent on a Linux instance, install Java, or check whether an instance requires a disk resize. By using common commands, you can simplify complex configurations and significantly improve your O&M efficiency.
Procedure
Use one of the following methods to view and run common commands.
ECS console
In the top navigation bar, select the region and resource group of the resource that you want to manage.
On the ECS Cloud Assistant page, click the Common Commands tab.
This tab lists the official common commands from Alibaba Cloud.
Find the common command that you want to run and click Run.
NoteThe Common Commands page displays only the latest version of each command. To view or run a previous version, find the command and click its command ID to go to the details page.
In the Run Command panel, configure the parameters and click Run.
The following table describes the main parameters.
Section
Parameter
Description
Command Information
Command content
Click View command content to review the script.
Execution plan
Select when to run the command. Valid values:
Immediate execution
After the next startup of the system
After each system startup
Timing execution
For more information about execution plans, see execution plan details.
Execution user
The user that runs the command on the ECS instance, for example, root.
By default, commands are run as the
rootuser on Linux instances and as theSystemuser on Windows instances.Timeout
The timeout in seconds, which must be an integer between 10 and 86,400. If a command exceeds this timeout, it is forcibly terminated. The default is the timeout defined in the command.
Command parameters
If this section appears, enter the custom parameter values. The parameters displayed vary based on the command.
NoteIf the command provider offers descriptions, default values, or allowed values, enter the parameters as prompted. If a parameter is required, you must enter a value to run the command.
Select Instances
-
Select one or more instances on which to run the command. The instances must be in the Running state and have the Cloud Assistant Agent installed.
Select Managed Instances
-
Select the managed instances on which to run the command. The instances must be in the Connected state and have the Cloud Assistant Agent installed.
NoteA managed instance is a non-Alibaba Cloud server managed by Cloud Assistant. For more information, see Managed instances.
NoteFor more information about the parameters for running a command, see Run a command in the ECS console.
On the Command execution result tab, find the successful execution record and click View in the Actions column.
On the execution details page, if the execution status of the instance is Successfully Executed, you can view the output of the common command.
NoteIf a command fails to run, check the error message and fix the issue based on the diagnostic information. For more information, see Common errors and solutions for failed executions.
OpenAPI
View common commands.
Call the DescribeCommands API operation to view common commands. You can also query for commands by name.
When you view common commands, take note of the following parameters:
Name: The name of the command. For example, to view the common command ACS-ECS-DiskResize-Diagnostic-for-linux.sh in the China (Hangzhou) region, set the name to ACS-ECS-DiskResize-Diagnostic-for-linux.sh.
Provider: The provider of the common command. Set this to AlibabaCloud to query for all common commands provided by Alibaba Cloud.
Run a common command.
You can execute a Cloud Assistant common command by calling InvokeCommand with the
CommandIdparameter value returned in step 1 above, or by directly using the command name. The names of common commands are the same across different regions.When you run a common command, take note of the following parameter:
CommandId: The ID of the command. For common commands, you can set this parameter to the command name to run the command. In this example, the value is ACS-ECS-DiskResize-Diagnostic-for-linux.sh.
A successful call returns the
InvokeIdparameter, such ast-hz02kwqc9pg****, which is the ID of the command execution. You can then call the DescribeInvocations or DescribeInvocationResults operation to query the execution results.You can also view the detailed output on the execution details page in the console to check, for example, whether the Linux instance in this example requires a disk resize.
CLI
View common commands by using Alibaba Cloud CLI.
You can call the DescribeCommands operation to view common commands.
When the
Providerparameter is set toAlibabaCloud, this indicates that all common commands provided by Alibaba Cloud are queried.If this parameter is set to a specific provider, all common commands from that provider are queried.
The following example shows how to query all common commands provided by Alibaba Cloud in the China (Hangzhou) region:
aliyun ecs DescribeCommands \ --region 'cn-hangzhou' \ --RegionId 'cn-hangzhou' \ --Provider 'AlibabaCloud'The following example shows how to query the common command
ACS-ECS-DiskResize-Diagnostic-for-linux.shin the China (Hangzhou) region. You can use this command to diagnose whether a Linux instance requires a disk resize.aliyun ecs DescribeCommands \ --region 'cn-hangzhou' \ --RegionId 'cn-hangzhou' \ --CommandId 'ACS-ECS-DiskResize-Diagnostic-for-linux.sh'
Run a common command by using Alibaba Cloud CLI.
Call the InvokeCommand operation to run a Cloud Assistant common command on one or more ECS instances.
For example, the common command
ACS-ECS-DiskResize-Diagnostic-for-linux.shis used to diagnose whether a Linux instance requires a disk resize operation. The following is an example:aliyun ecs InvokeCommand --RegionId 'cn-hangzhou' \ --InstanceId.1 'i-bp1f4f6o8lv0wqof****' \ --InstanceId.2 'i-bp137qu6142s3mhm****' \ --CommandId 'ACS-ECS-DiskResize-Diagnostic-for-linux.sh' \ --Timed 'false'After a successful call, you will obtain a return parameter named
InvokeId(for example,t-hz03rj5u0jx****), which is the execution ID of the common command. You can call the DescribeInvocations or DescribeInvocationResults operation to query the execution results of the Cloud Assistant command. The following is an example:aliyun ecs DescribeInvocations --RegionId 'cn-hangzhou' \ --InvokeId 't-hz03rj5u0jx****'You can also view the detailed output on the execution details page in the console to check, for example, whether the Linux instance in this example requires a disk resize.