How to cancel a hang task in vCenter or ESXi host?

By | November 14, 2017

Recently my customer wanted to cancel a "creating a snapshot" task. The task was created by backup application. Unfortunately the cancel option was greyed so wow to cancel it? I will show this in the following post.

At first you have to investigate where a hang process exists (Clicking summary tab on VM). Then:

  1. Log in to ESXi host via SSH (using e.g. putty). If the SSH service is not running on ESXi host, please enable it.

To enable SSH from the vSphere Client:

  • Select the host and click the Configuration tab.
  • Click Security Profile in the Software panel.
  • In the Services section, click Properties.
  • Select SSH and click Options.
  • Change the SSH options.
  • Click OK.
  1. Run ps command. If you face problems to find the running processes related to the VM please use grep e.g. ps | grep VM_name. In the below example, I looked for VM named: SPDB1CEN-T:kill_task
  2. Kill the parent process by running the command kill id_parent. In my case: kill 84695.
  3. The hang task should be canceled now.

It is also possible just to reboot ESXi host (after doing vMotion of other VMs) to solve the issue.

Note: Please follow snapshots best practices and recommendations to avoid problems with them and how to delete snapshots automatically.

Update: You can try the below options:

  1. Log in to ESXi host via ssh.
  2. Run esxcli vm process list to get world id of VM.
  3. Power off the virtual machine from the list by running this command: esxcli vm process kill --type= [soft,hard,force] --world-id= WorldNumber
Author: Mariusz

Architect (~ 15 years experience based on passion...) with strong background as a System Administrator and Engineer. Focused on Data Center Solutions: Virtualization/Cloud Computing and Storage/Backup Systems. Currently living in Poland.