User Tools

Site Tools


os:esxi:cli

This is an old revision of the document!


ESXi - CLI

Manually start 'Auto power on' procedure

This may be useful after exiting maintenance mode. The following command will start the VM's like described in /etc/vmware/hostd/vmAutoStart.xml.

~ # vim-cmd hostsvc/autostartmanager/autostart

The execution takes some time. It will start one VM after another.

Shutdown all powered on VM's

This command will get all running VM's, determine the Vmid and initiate a guest shutdown for all of them. Use it at your own risk.

~ # for vmid in $(vim-cmd vmsvc/getallvms | egrep "$(esxcli vm process list | grep "^[^ ]" | xargs | sed 's/ /|/g')" | awk '{ if($1 ~ /^[0-9]*$/ ) { print $1} }'); do vim-cmd vmsvc/power.shutdown $vmid; done

Poweroff or kill a VM

Attention: This is a power off, not a guest shutdown. This is not the prefered way to shutdown your VM's.

First, to get a list of your running VM's and the corresponding World ID execute the following command:

~ # esxcli vm process list
my_vm_x
   World ID: 35930
   Process ID: 0
   VMX Cartel ID: 35699
   UUID: 56 4d 67 bf 2c 52 e1 e0-33 1b 57 42 02 d8 d8 3b
   Display Name: my_vm_x
   Config File: /vmfs/volumes/5463f5fa-e9e1b35a-983d-6451066626e8/my_vm_x/my_vm_x.vmx

my_vm_y
   World ID: 36398
   Process ID: 0
   VMX Cartel ID: 36397
   UUID: 56 4d f9 f5 10 4e fa e0-42 e8 80 17 a2 bf b5 93
   Display Name: my_vm_y
   Config File: /vmfs/volumes/5463f5fa-e9e1b35a-983d-6451066626e8/my_vm_y/my_vm_y.vmx

This is how the kill command is constructed:

~ # esxcli vm process kill --type={soft,hard,force} --world-id={world id}

Use the type in this order. Try a soft kill first. If the VM wont power off try hard and if it doesn't work try force as last option.

For example:

~ # esxcli vm process kill --type=soft --world-id=35930

and if soft is not enough:

~ # esxcli vm process kill --type=hard --world-id=35930
~ # esxcli vm process kill --type=force --world-id=35930
os/esxi/cli.1437858442.txt.gz · Last modified: 2015-07-25 23:07 by root