Today I will outline the options to kill an unresponsive OpenVZ container.

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 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 shutdown the container without stopping the services inside the container by init script first. Use this switch only when the normal stop fails as a hard shutdown of services may cause data loss or inconsistencies in databases.

vzctl stop 101 --fast

Kill processes inside a 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 to try this.

ps ax | awk '{print $1}' | xargs vzpid | grep 101 | awk '{print $1}' | xargs kill -9
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *

*