This guide shows you how to kill an unresponsive OpenVZ container in case the normal stop procedure fails. Killing the container will not delete any files or remove the container, it just kills all processes so that you can start or restart the container again when it gets stuck.
I will use container ID 101 in all commands, please replace that ID with the ID of the container that you like to kill.
Try to stop the OpenVZ container
The first step should be to try to stop the container the normal way. The stop command tries to invoke the init scripts inside the container to shut down all services, so it requires the cooperation of the scripts inside the container.
The stop command is:
vzctl stop 101
If you get a timeout after some time, then try the next option.
Use --fast switch to kill the OpenVZ Container
The --fast option tries to shut down the container without stopping the services inside the container by init script first. Use this switch only when the normal stop fails. A hard shutdown of services may cause data loss or inconsistencies in databases.
vzctl stop 101 --fast
Kill processes inside an OpenVZ Container
Here is a short script that kills all processes of a given VM. If the two above methods fail, then it's worth trying this.
ps ax | awk '{print $1}' | xargs vzpid | grep 101 | awk '{print $1}' | xargs kill -9