• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Yellow Bricks

by Duncan Epping

  • Home
  • ESXTOP
  • Stickers/Shirts
  • Privacy Policy
  • About
  • Show Search
Hide Search

The Basics: How to kill a VM that’s stuck during shutdown?

Duncan Epping · Apr 15, 2009 ·

I just replied to a topic on the VMTN forums and thought it might be useful to write it down here as well. (I thought I already did, but a search didn’t turn up anything.)

When a VM gets stuck during shutdown or isn’t responding anymore you can easily kill the VM. First option is the command line version of vCenter’s “shutdown vm”, first list all the VMs running on the host so you can copy and paste the <config> in to the next command. The command “vmware-cmd <config> stop trysoft” will try to initiate a soft shutdown first, in other words a shutdown via the Guest OS, if that doesn’t work it will do a power off. Now, as most of you probably already experienced, sometimes it’s impossible to shutdown the VMs in a normal way. This is where 2nd, 3rd and 4th option come in to place. Option two uses vm-support to kill the VM, use “-x” to list the VM id’s and kill it with “-X”. The third option uses vimsh, in this case we use vmware-vim-cmd, “vmsvc/getallvms” lists all VMs and the id’s and with “vmsvc/poweroff” you can specify the VM that needs to be powered off. The fourth option is the Linux/Unix way of doing it, find the process id of the VM via “ps -auxwww” and just kill it.

  1. vmware-cmd -l
    vmware-cmd <config> stop trysoft
  2. vm-support -x
    vm-support -X <vmid>
  3. vmware-vim-cmd vmsvc/getallvms
    vmware-vim-cmd vmsvc/poweroff <vm id>
  4. ps -auxwww | grep <vm name>
    kill <process id>
  5. if option three isn’t successful do the following:
    kill -9 <process id>

As VMwareWolf points out, there’s an excellent KB article on this subject to be found here: http://kb.vmware.com/kb/1004340

Share it:

  • Tweet

Related

Server basics, ESX, service console

Reader Interactions

Comments

  1. VMwarewolf says

    15 April, 2009 at 13:29

    I believe the Knowledge base article you were looking for that discusses this is at: http://kb.vmware.com/kb/1004340

  2. Jason Boche says

    15 April, 2009 at 13:31

    Good stuff.

    Back in the GSX Server days, I would use ‘vmware-cmd stop trysoft hard’ in my shutdown scripts. Is ‘hard’ implied now if ‘trysoft’ does not work?

    I wasn’t aware of the -x option to grab the PID. My method is to use ESXTOP, and use ‘e’ to expand the PIDs of a particular VM. The method you demonstrate here is quicker.

    Jas

  3. Jason Boche says

    15 April, 2009 at 13:32

    Oh, and option 3 – who can remember all those silly little switches, except for Linux folks 🙂

  4. devnull says

    15 April, 2009 at 15:36

    I’ve had some success using vimsh where vmware-cmd will not work.

    In vimsh:
    vmsvc/getallvms (find the vmid you are looking for)
    vmsvc/poweroff $vmid

  5. William says

    15 April, 2009 at 16:37

    Good article for reference, this issue does come up pretty often on the VMTN forums and I had just answered two questions last week regarding the same issue. Too bad there is not an equilv for ESXi, at least as far as I’m aware of.

    @devnull – vmware-cmd is actually depreciated command, it works pretty well for the most part but there are times where it’ll just act up. I’m sure you could potentially get into the same issue as using vimsh or the vimsh wrapper. In either case, it’s good to know how to find the process and kill it.

  6. Cody Bunch says

    15 April, 2009 at 16:38

    Another post on the same. Nice to have the info in more hands: http://professionalvmware.com/2008/12/04/killing-a-stuck-or-hung-vm/

    -Cody Bunch
    http://professionalvmware.com

  7. Joe User says

    18 November, 2012 at 11:02

    vmrun –help

    or (eg)

    vmrun -T ws stop /path/to/your/file/blah.vmx soft

Primary Sidebar

About the author

Duncan Epping is a Chief Technologist in the Office of CTO of the Cloud Platform BU at VMware. He is a VCDX (# 007), the author of the "vSAN Deep Dive", the “vSphere Clustering Technical Deep Dive” series, and the host of the "Unexplored Territory" podcast.

Upcoming Events

Feb 9th – Irish VMUG
Feb 23rd – Swiss VMUG
March 7th – Dutch VMUG
May 24th – VMUG Poland
June 1st – VMUG Belgium

Recommended Reads

Sponsors

Want to support Yellow-Bricks? Buy an advert!

Advertisements

Copyright Yellow-Bricks.com © 2023 · Log in