Skip to main content

I’ve seen this multiple times now with VMware. You cancel a task via vCenter or the ESXi UI and it just stays there hanging and nothing further happens. Normally this situation resolves itself after some time, but just last week I had a case where the task never stopped. While the Webclients weren’t really helpful in that case, we were able to cancel this task with the ESXi commandline.

Warning: Interupting certain tasks, for example snapshot consolidations or Storage vMotions, can lead to issues or corrupted VMs. So only do this if you don’t have any alternatives and need the task to be canceled. And better have a backup at your hand.

Solution

  1. Start the SSH service on the ESXi host where your VM is registered
  2. Connect via SSH
  3. Query the VM ID: vim-cmd vmsvc/getallvms
  1. Query all tasks for this VM: vim-cmd vmsvc/get.tasklist “VM ID”
  1. Check the Task information: vim-cmd vimsvc/task_info “haTask….”
    1. Is the task still state still active?
    2. Note: The screenshot is just an example; the task state is success, so it’s completed
  2. Chancel the task: vim-cmd vimsvc/task_cancel “haTask….”

This should be it. Afterwards you can check in the task info whether the task has been canceled successfully. If you have multiple active tasks, then first try to stop the oldest one and wait if all further tasks get cleaned up later on.

 

Source: VMware Knowledge Base

I have used this many times when troubleshooting tasks in VMware.   Great way if the UI is not working.


I did not know you could cancel tasks via the CLI….I should have figured it was there, but have never done it.  Thank you for this tidbit!


I did not know you could cancel tasks via the CLI….I should have figured it was there, but have never done it.  Thank you for this tidbit!

It is great when troubleshooting things and needing to kill a VM.  😋


I’ve killed VM’s from the CLI, just not cancelled tasks...


Yes, vim-cmd is - I guess - not that widely known. Thank you for bringing it before the curtain!


Great reminder @regnor 


This process hasn’t worked for me. My VM has been “hung up” for about a week now. I have a backup server on this host as well, so I need to be careful with the steps I take to resolve it.


Comment