Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to configure my servers to use NTP. I would like them all to use GMT time zone. I would like to use public NTP server how do I do it?

share|improve this question
1  
If you do this please also explain to your users how to use the TZ environment variable... –  voretaq7 May 9 '11 at 17:57
    
It's not necessary to have your server keep time in UTC to use NTP correctly. –  Chris S May 9 '11 at 18:08
add comment

2 Answers

up vote 4 down vote accepted

To configure the timezone link /etc/localtime to the file in /usr/share/zoneinfo which matches the timezone that you want

date 
Mon May  9 09:18:22 BST 2011

sudo mv /etc/localtime /etc/localtime.old
sudo ln -s /usr/share/zoneinfo/GMT /etc/localtime

date
Mon May  9 08:19:42 GMT 2011

To install ntp (if it's not already)

sudo yum install ntp
sudo chkconfig ntpd on
sudo service ntpd start

EDIT:

As far as I'm aware the default /etc/ntp.conf will contain all the public servers you require. If however you need to you can add the following server configurations

server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

You can use the ntpq command to see if it's working.

/usr/sbin/ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*time.nist.gov   .ACTS.           1 u  397 1024  357  147.843    1.518   4.840

the offset value tells you how how far out of sync you are

share|improve this answer
    
don't I need to configure ntpd.conf for publie NTP servers? how do I check if ntpd works? –  edotan May 9 '11 at 13:10
    
thank you but when I do it and check "date" I get UTC and not GMT: mv /etc/localtime /etc/localtime.old ln -s /usr/share/zoneinfo/GMT /etc/localtime date Mon May 9 14:34:02 UTC 2011 –  edotan May 9 '11 at 14:34
    
I only see the UTC variant if there is no /etc/localtime - check that it exists and is correctly linked to /usr/share/zoneinfo/GMT –  Iain May 9 '11 at 14:50
    
this is what I see:/etc/localtime -> /usr/share/zoneinfo/GMT cat /etc/localtime TZif2 GMT0 –  edotan May 9 '11 at 15:08
    
On my CentOS 5.5 & 5.6 systems it all works as described above. Have you got a TZ environment vatiable set e.g. TZ=UTC ? If you don't then I'm out of ideas. –  Iain May 9 '11 at 15:29
show 1 more comment

To set the timezone to GMT use:

$ sudo rm /etc/localtime

$ sudo ln -s /usr/share/zoneinfo/GMT /etc/localtime


To install NTP use:

$ sudo yum -y install ntp

And make it active with:

$ sudo chkconfig ntpd on

$ sudo service ntpd start

share|improve this answer
    
Is London really GMT? I was under the impression that they went to "Summer Time" every year (similar to Daylight Savings Time here in the US). –  mdpc May 9 '11 at 18:35
    
@mdpc: your right, I copied it from a server I configured a couple of days before, and forgot to change it to GMT. I edited the answer, so it should be correct now. –  dgrimbergen May 9 '11 at 20:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.