Kill an OpenVZ Container – e.g id 900
vzctl stop 900
Use –fast switch to kill the OpenVZ Container – crude non graceful
vzctl stop 900 –fast
Kill processes inside a OpenVZ Container
ps ax | awk '{print $1}' | xargs vzpid | grep 900 | awk '{print $1}' | xargs kill -9
Commonly used commands:
1, Command to list the running VPSs in a node
# vzlist
Example:
# vzlist
CTID NPROC STATUS IP_ADDR HOSTNAME
106 104 running xx.xx.xx.xx server1.test.com
107 46 running xx.xx.xx.xx server2.test.com
108 83 running xx.xx.xx.xx server3.test.com
109 86 running xx.xx.xx.xx server4.test.com
2, Command to list running and stopped VPSs in an node
This command lists all the VPSs in a node.
# vzlist -a
Example:
# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
900 104 running xx.xx.xx.xx serverfoo1.com
901 46 running xx.xx.xx.xx serverfoo2.com
902 83 running xx.xx.xx.xx serverfoo3.com
903 86 running xx.xx.xx.xx serverfoo4.com
904 – stopped xx.xx.xx.xx serverf005.com
3, To start a VPS
# vzctl start CTID
Example:
# vzctl start 900
4, To stop or shutdown a VPS
# vzctl stop CTID
Example:
# vzctl stop 900
5, To view the status of a VPS
# vzctl status CTID
Example:
# vzctl status 904
CTID 900 exist unmounted down
6, To enter a VPS
# vzctl enter CTID
Example:
# vzctl enter 900
entered into CT 900
7, Set hostname for a Server
# vzctl set CTID --hostname New_hostname --save
8, Add new IP to VPS
# vzctl set CTID --ipadd xx.xx.xx.xx --save
9, Delete IP from VPS
# vzctl set CTID --ipdel xx.xx.xx.xx --save
10, Reset root password of a VPS
# vzctl set CTID --userpasswd root:new_password --save
11, To add NameServer IPs to VPS
# vzctl set CTID --nameserver xx.xx.xx.xx --save
12, Delete a container
# vzctl destroy CTID
13, Suspending a container
# vzctl suspend CTID