2

Is there any way to shutdown a VMware vshere server (Esxi) over ssh. I know Esxi is not really UNIX anymore so shutdown command will not work but the reboot command does seem to work. Is there an equivalent to shutdown?

2 Answers 2

5

To make a more complete answer, to do an orderly shutdown, you need to:

  1. shut down or suspend all running virtual machines(*)
  2. put the ESXi host in maintenance mode
  3. shut donw the host

1 - Shutdown or suspend the VMs:

Get the list of VMs with

vim-cmd vmsvc/getallvms

Get the status for each, by using the number from the previous parameter, to check which ones are running and need to be suspended or turned of:

vim-cmd vmsvc/power.getstate #

For those which are powered on:

vim-cmd vmsvc/power.shutdown # or vim-cmd vmsvc/power.suspend #

NOTE: this is to gracefully suspend or shutdown, which depends on VMWare Tools being installed on the OS. This options powers it off directly, for example for VMS without VMWare tools (unless you want to shs them and turn them down by other means):

vim-cmd vmsvc/power.off #

2 - Put host in maintenance mode

esxcli system maintenanceMode set --enable true

This command keeps locked until the host is in maintenance mode. For example, it can wait fro the VMs to finish suspending or shutting down.

3 - Shut down the host

esxcli system shutdown poweroff --reason "A good reason to turn you off!!"

(*) if you're on vCenter, you can also migrate them to a different server

4

Yes - the poweroff command should work when you are connected via ssh to the ESXi server.

Source: https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1013193

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .