Before synchronizing your Linux box to a NTP server you should assure it is correctly set to your current timezone.
Setting the timezone on CentOS or Redhat Enterprise Linux (RHEL) is straightforward.
1. See what the current timezone is:
You should see something like this:
mar nov 13 14:53:56 CET 2012
where CET stands for “Central European Time”.
2. To change the timezone first look at what timezones are available by running the following command on the command line interface:
# ls /usr/share/zoneinfo/
You’ll get something like this:
[root@server ~]# ls /usr/share/zoneinfo/ Africa Asia Canada Cuba EST Factory GMT0 Hongkong Iran Japan Mexico Navajo Poland PRC ROK Universal W-SU America Atlantic CET EET EST5EDT GB GMT-0 HST iso3166.tab Kwajalein Mideast NZ Portugal PST8PDT Singapore US zone.tab Antarctica Australia Chile Egypt Etc GB-Eire GMT+0 Iceland Israel Libya MST NZ-CHAT posix right Turkey UTC Zulu Arctic Brazil CST6CDT Eire Europe GMT Greenwich Indian Jamaica MET MST7MDT Pacific posixrules ROC UCT WET
3. Delete the current timezone:
4. Make a symbolic link to the new timezone file:
# ln –s /usr/share/zoneinfo/America/New_York /etc/localtime
Now it’s time to synchronize the system clock to a NTP server.
Network Time Protocol (NTP) is a standard way of synchronizing computer clocks across a network. Using NTP you can keep your server’s clock synchronized with super accurate atomic clocks located around the world. Computer clocks tend to “drift” so regularly synchronizing them with NTP servers helps keep them accurate.
5. Install if necessary the ntp tools:
# yum install ntp
6. Synchronize to the NTP server:
# ntpdate 0.us.pool.ntp.org
You can either use any public NTP server available worldwide or your own server connected to your LAN. You can find a complete list of public NTP servers at http://www.ntp.org
6. In order to maintain the system clock synchronized over time, it is highly recommended to start the NTP daemon which will correct the drifts between your server and the NTP server’s clock. Edit /etc/ntp.conf and set the correct server to use:
Don’t forget to comment out the following lines that can prevent ntpd to synchronize properly with the server:
#server 127.127.1.0 # local clock #fudge 127.127.1.0 stratum 10
7. Start NTPD service up:
# service ntpd start
8. Make it run automatically at boot up:
# chkconfig ntpd on
9. Last but not least, “save” your current time to your hardware clock:
# hwclock --systohc