VM with stuck task is not responding on ESXi 5.x

I was called in one evening with a request to fix an important SQL Server virtual machine that had frozen and was not responding to pings, remote desktop and the vSphere console was not displaying. All attempts to power off the virtual machines did not work vSphere reported that another task was running. I used vSphere client to log directly into the host and found that a create snapshot task had been “stuck” for the last 14 hours. To fix this problem turned on ssh for the host and used putty to start an ssh session to connect to the esxshell for the host.

First I needed to determine the world id of the virtual machine. This is done with the following command:

esxcli vm process list

The result of this command will list all VMs in the host and the world-id will be displayed.

Next I killed the VMs process using the world-id <world-id> obtained earlier and the following command:

esxcli vm process kill --type=force --world-id=<world-id>

To restart the VM, I went back to vSphere and Powered on the VM the normal way.

Machine started normally.