This topic describes how to run Cloud Assistant commands with specified exit codes to stop or restart Elastic Compute Service (ECS) instances.
Prerequisites
The instances that you want to stop or restart are in the Running (Running) state.
Cloud Assistance Agent is installed on the instances. For more information, see Install the Cloud Assistant Agent.
Cloud Assistant Agent is of one of the following versions or later:
Linux: 2.2.3.317
Windows: 2.1.3.317
If an error is reported when you run a command with a specified exit code, upgrade Cloud Assistant Agent to the latest version. For more information, see Upgrade or disable upgrades for the Cloud Assistant Agent.
Background information
When you run a Cloud Assistant command to stop or restart instances, we recommend that you append a specified exit code to the end of the command to ensure that the command execution states are accurate in real time. If you run a Cloud Assistant command without an exit code to stop or restart instances, the execution states of the command may not be correctly updated even when the command finishes with the stop or restart operation. This is because Cloud Assistant Agent does not save execution states of the command before the command is run to stop or restart the instances.
Procedure
- Log on to the ECS console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
In the upper-right corner, click Create/Run Command.
In the Command Information section, configure parameters. For more information, see Use the immediate execution feature.
In the Enter Command Content code editor, add an exit code to the end of the specified command.
To run a command to stop instances, specify one of the exit codes described in the following table based on the operating system type of the instances.
Operating system
Exit code
Sample command
Linux
193
# If the following shell command returns an exit code of 193, an operation is triggered to stop specified instances. exit 193
Windows
3009
# If the following PowerShell command returns an exit code of 3009, an operation is triggered to stop specified instances. exit 3009
To run a command to restart instances, specify one of the exit codes described in the following table based on the operating system type of the instances.
Operating system
Exit code
Sample command
Linux
194
# If the following shell command returns an exit code of 194, an operation is triggered to stop specified instances. exit 194
Windows
3010
# If the following PowerShell command returns an exit code of 3010, an operation is triggered to stop specified instances. exit 3010
In the Select Instances or Select Managed Instances section, select the instances on which you want to run the command.
NoteA managed instance is an instance that is not provided by Alibaba Cloud but managed by Cloud Assistant. For more information, see Manage servers that are not provided by Alibaba Cloud.
Click Execute and Save or Run to immediately run the command task.