This topic describes how to call the RebootInstance operation by using Alibaba Cloud command-line interface (CLI) to restart an ECS instance.

Background information

You can call the RebootInstance operation to restart an ECS instance that is in the running state. After the call succeeds, the instance enters the starting state. For more information, see RebootInstance.

When you call an API operation through Alibaba Cloud CLI, make sure that request parameter values of different data types are in required formats. For more information, see Parameter format overview.

Request examples

  1. Call the DescribeInstances operation to query the ID of the ECS instance that you want to restart.

    In this example, query the ID of an ECS instance by using its name.

    aliyun ecs DescribeInstances --RegionId cn-hangzhou --InstanceName namedemo --Status Running --output cols=Instances.Instance[].InstanceId
    Sample response:
    Instances.Instance[].InstanceId
    -------------------------------
    [i-bp14a7xie8erwsvo****]
  2. Restart ECS instance i-bp14a7xie8erwsvo****, which is in the running state.

    In this example, the ECS instance is stopped properly and it starts directly after the pre-check.

    aliyun ecs RebootInstance --InstanceId i-bp14a7xie8erwsvo**** --ForceStop false --DryRun false

Result

{
        "RequestId": "2DD09CBD-1F4D-4923-94C7-F3BD67137BBE"
}