User`s guide
Advanced Tasks 64
Determining VPS ID by Process ID
Each process is identified by a unique PID (process identifier), which is the entry of that process
in the kernel's process table. For example, when you start Apache, it is assigned a process ID.
This PID is then used to monitor and control this program.The PID is always a positive integer.
In OpenVZ you can use the
vzpid (retrieve process ID) utility to print the Virtual Private
Server ID the process with the given id belongs to. Multiple process IDs can be specified as
arguments. In this case the utility will print the Virtual Private Server number for each of the
processes.
The typical output of the
vzpid utility is shown below:
[root@ts23 root]# vzpid 12
Pid VPS Name
12 4 init
In our example the process with the identifier 12 has the name 'init' and is running in the Virtual
Private Server with ID = 4.
Changing System Time from VPS
Normally it is impossible to change the system time from a Virtual Private Server. Otherwise,
different Virtual Private Servers could interfere with each other and could even break
applications depending on the system time accuracy.
Normally only the Hardware Node system administrator can change the system time. However,
if you want to synchronize the time via Network Time Protocol (NTP), you have to run NTP
software, which will connect to external NTP servers and update the system time. It is not
advisable to run application software on the Hardware Node itself, since flaws in the software
can lead to compromising all Virtual Private Servers on the Hardware Node. Thus, if you plan
to use NTP, you shall create a special Virtual Private Server for it and configure it to have the
sys_time capability. The example below illustrates configuring such a Virtual Private Server:
# vzctl set 101 --capability sys_time:on --save
Unable to set capability on running VPS
Saved parameters for VPS 101
The output of the above command warns you that vzctl cannot apply changes in the
capabilities to a running Virtual Private Server. The VPS has to be restarted before changes take
effect:
# vzctl restart 101
Restarting VPS
Stopping VPS ...
VPS was stopped
VPS is unmounted
Starting VPS ...
VPS is mounted
Adding IP address(es): 192.168.1.101
Hostname for VPS set: vps101.my.org
VPS start in progress...
# ssh root@vps101