Previous page

Next page

Locate page in Contents

Print this page

Changing System Time from Containers

Normally, it is impossible to change the system time from a Container. Otherwise, different Containers could interfere with each other and could even break applications depending on the system time accuracy.

Usually 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 may lead to compromising all Containers on this Hardware Node. Thus, if you plan to use NTP, you should create a dedicated Container and allow it read/write access to the real-time clock with the --devnodes command. The example below illustrates configuring such a Container:

# vzctl set 101 --devnodes rtc:rw --save

Now you can enter the Container and change the system time from it. For example:

# ssh root@ct101

root@ct101's password:

Last login: Mon Feb 28 23:25:58 2007 from 10.100.40.18

[root@ct101 root]# date

Mon Feb 28 23:31:57 EST 2007

[root@ct101 root]# date 10291300

Tue Oct 29 13:00:00 EST 2007

[root@ct101 root]# date

Tue Oct 29 13:00:02 EST 2007

[root@ct101 root]# logout

Connection to Container101 closed.

# date

Tue Oct 29 13:01:31 EST 2007

The changes will affect both the Containers and the Hardware Node itself. It is not advisable to have more than one Container with the access to the real-time clock.

NTP is described in the Internet Standard RFC 1305. For more information, visit http://www.ntp.org.