OpenVZ Forum


Home » General » Support » How to set time in OpenVZ VPS?
How to set time in OpenVZ VPS? [message #37387] Sat, 05 September 2009 20:16 Go to next message
vivithemage is currently offline  vivithemage
Messages: 15
Registered: September 2009
Location: Minnesota
Junior Member
I have the correct time on the node, but the VPS's themselves will not get the correct time. I get a permission error when doing ntpdate pool.ntp.org on the VPS.
Re: How to set time in OpenVZ VPS? [message #37389 is a reply to message #37387] Sat, 05 September 2009 23:07 Go to previous messageGo to next message
tomp is currently offline  tomp
Messages: 64
Registered: August 2007
Member
The VPS will take the time from the hardware node, so just use NTP on the hardware node.
Re: How to set time in OpenVZ VPS? [message #37390 is a reply to message #37389] Sat, 05 September 2009 23:16 Go to previous messageGo to next message
vivithemage is currently offline  vivithemage
Messages: 15
Registered: September 2009
Location: Minnesota
Junior Member
but they aren't...they are totals wrong, a few hours off...some are a day or two off.
Re: How to set time in OpenVZ VPS? [message #37391 is a reply to message #37390] Sun, 06 September 2009 09:30 Go to previous messageGo to next message
marc@ion is currently offline  marc@ion
Messages: 3
Registered: September 2009
Junior Member
OpenVZ does take the time from the HN, but it doesn't take the timezone.

Depending on your distribution, there are other ways to set a timezone.

In Ubuntu:
dpkg-reconfigure tzdata

Best regards,

MM
Re: How to set time in OpenVZ VPS? [message #37393 is a reply to message #37391] Sun, 06 September 2009 15:50 Go to previous messageGo to next message
vivithemage is currently offline  vivithemage
Messages: 15
Registered: September 2009
Location: Minnesota
Junior Member
how about in centos?

Re: How to set time in OpenVZ VPS? [message #37400 is a reply to message #37387] Sun, 06 September 2009 20:48 Go to previous messageGo to next message
divB is currently offline  divB
Messages: 79
Registered: April 2009
Member
Please lookup up in the Wiki and/or the manual.

There must be only one place where the time is set. Either on the HN or one container.

It is even recommended to use a container and set the time with NTP within one container for security reasons. In this case you have to:

a) assign a capability SYS_TIME to set the system time
b) give access to the /dev/rtc0 device if you want to also set the time back to the RTC clock

The time set will the UTC and all container use UTC+offset as their system time whereas offset is a constant specific for each container, usually the time zone and/or daylight saving. You have to lookup in the CentOS docs how to set the timezone there (this is an OpenVZ forum Wink ).

Regards,
divB
Re: How to set time in OpenVZ VPS? [message #37401 is a reply to message #37400] Sun, 06 September 2009 20:51 Go to previous messageGo to next message
vivithemage is currently offline  vivithemage
Messages: 15
Registered: September 2009
Location: Minnesota
Junior Member
How would I do that? I would prefer to have the hardware node actually handle the time, not a container.

Could you link me the wiki article? I tried searching it, but it came up with no good results.

I was trying to set NTP in the centos's located in my OpenVZ nodes, that's why I came here, because I was getting restriction errors, saying I cannot install NTP.
Re: How to set time in OpenVZ VPS? [message #37402 is a reply to message #37401] Sun, 06 September 2009 20:56 Go to previous messageGo to next message
divB is currently offline  divB
Messages: 79
Registered: April 2009
Member
1.) If you want to set the time on the hardware node you do not have to care about anything. Just run ntpdate <ntp-server> and additionally hwclock. Please consult the CentOS manual on how to install ntpdate (or use a system that you can handle Wink )

2.) If you want to set the time through a container as explained by me, look up for a PDF called "OpenVZ User's guide". There is a section "Changing System Time from VPS".

Regards,
divB

Re: How to set time in OpenVZ VPS? [message #37406 is a reply to message #37402] Mon, 07 September 2009 02:48 Go to previous messageGo to next message
vivithemage is currently offline  vivithemage
Messages: 15
Registered: September 2009
Location: Minnesota
Junior Member
ntupdate is good, the node is up to date/time.

How do I make sure the VPS's use that clock and not whatever they are currently using?

I have not heard of hwclock, and google is proving useless on that.

again, I do not want to use a container to keep other containers up to date.
Re: How to set time in OpenVZ VPS? [message #37407 is a reply to message #37387] Mon, 07 September 2009 08:42 Go to previous messageGo to next message
Xahil is currently offline  Xahil
Messages: 7
Registered: December 2007
Junior Member
google: "centos setting timezone"

first hit: http://forum.slicehost.com/comments.php?DiscussionID=1180

Re: How to set time in OpenVZ VPS? [message #37408 is a reply to message #37407] Mon, 07 September 2009 08:59 Go to previous messageGo to next message
divB is currently offline  divB
Messages: 79
Registered: April 2009
Member
Your containers will automatically use "that clock".

hwclock is a tool to modify the RTC. You can either set the system clock from the RTC (this is done on startup) or save the current system clock to RTC.

If you have a 24x7 system with guaranteed internet connection and use ntpdate you may no need to use the RTC.
Re: How to set time in OpenVZ VPS? [message #37413 is a reply to message #37407] Mon, 07 September 2009 18:21 Go to previous messageGo to next message
vivithemage is currently offline  vivithemage
Messages: 15
Registered: September 2009
Location: Minnesota
Junior Member
there we go, this line worked great :

Quote:
rm /etc/localtime
ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime


icon14.gif  Re: How to set time in OpenVZ VPS? [message #37714 is a reply to message #37413] Tue, 13 October 2009 18:38 Go to previous messageGo to next message
zeldor is currently offline  zeldor
Messages: 3
Registered: October 2009
Junior Member

vivithemage wrote on Mon, 07 September 2009 20:21
there we go, this line worked great :

Quote:
rm /etc/localtime
ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime





thx it was really helpful, it worked great under debian 5.0.3 (lenny) even without restart or other extra stuff
Re: How to set time in OpenVZ VPS? [message #42142 is a reply to message #37400] Sun, 06 March 2011 16:22 Go to previous message
shamu is currently offline  shamu
Messages: 13
Registered: December 2010
Location: Upper Bavaria / Germany
Junior Member
I want a ntpd running in a container adjust the hw node's time (step a), see below) and the systems hw clock. As far as I know on not virtualized machinges it could be done using the command '/sbin/hwclock -w'. But, how to do it from within a container?

Quote:
It is even recommended to use a container and set the time with NTP within one container for security reasons. In this case you have to:

a) assign a capability SYS_TIME to set the system time
b) give access to the /dev/rtc0 device if you want to also set the time back to the RTC clock


Well, a) is o.k. and already done on my system. But, in detail, how can I perform step b) ?

Thanks for your help in advance!

Greetinx

shamu
Previous Topic: how to let container forward ip packets
Next Topic: Problem with limit od CPU.
Goto Forum:
  


Current Time: Thu May 09 23:41:22 GMT 2024

Total time taken to generate the page: 0.01522 seconds