How to terminate instance from shell? - Technical Help - DeepTalk - Deep Learning Community

How to terminate instance from shell?

post by justice on Jun 29, 2023

I’m trying to terminate my VM at the end of its run. shutdown -P 0 does nothing.

halt makes it go unresponsive. However, the dashboard then shows it with an “alert” status, and it is available to be terminated, so I assume I’m still paying for it until I do so.

Is there a way to terminate the VM from its own shell?

post by yanos on Jul 4, 2023

From the instance’s terminal, you can only shut down the operating system but you cannot terminate the instance so that it stops being charged.

One workaround is the following and you can run it from any PC or even from inside the instance.

  1. Generate a Lambda Cloud API Key

  2. Run this command to list all your instances:


curl -u API_KEY: https://cloud.lambdalabs.com/api/v1/instances \
-H "Content-Type: application/json"

output:


{
  "data": [\
    {\
      "id": "########",\
      "ip": "##.##.##.##",\
      "region": {\
        "name": "us-west-1",\
        "description": "California, USA"\
      }\
    }\
  ]
}

Find your instance id (“########”) and delete it:


$ curl -u API_KEY: \
https://cloud.lambdalabs.com/api/v1/instance-operations/terminate \
-d '{"instance_ids":["########"]}'

I hope this helps!