How to cancel a hang task in vCenter or ESXi host?
Sometime we may need to cancel an hung task like active vmotion/backup which may show as disabled from the vSphere client.
- First check if there is an active task running for the VM in the Task and Events Tab.
- Log in to ESXi host via SSH (using e.g. putty). If the SSH service is not running on ESXi host, please enable it.
- Run ps command. use grep e.g. ps | grep VM_name
- Kill the parent process by running the command kill id_parent e.g. kill 859467
- The hang task should be canceled now and will reflect in the Tasks and Events in the vCenter.
January 25, 2017 at 10:22 pm
Do not do this, this is a horrible suggestion without at least caveating what it does. The above command in step 3 will kill the VM — stop it cold. This will likely corrupt most systems and should only be done if you either are: 1) planning to restore from backup or 2) want to get rid of the vm anyways.
LikeLike
May 1, 2017 at 5:05 pm
it is better to proceed via powercli:
connect to vcenter or host by:
connect-VIServer [vcenter_ip]
find it by :
get-task -Status running | select ID, StartTime, IsCancelable| fl
kill it by:
Get-Task | where {$_.id -eq “Task-task-33529” } | stop-task -confirm:$false
LikeLike
August 11, 2017 at 8:46 pm
@Mehrantgs this will only “kill” or factually cancel a task if the task itself is cancelable. It will not end a task such as a Remidiation task within the Update Manager.
LikeLiked by 2 people
October 30, 2018 at 6:55 pm
There is no explanation here as to what the parent ID is…
LikeLike