Learn how to set the correct timezone and synchronize time with NTP servers on your CentOS box.
Setting the timezone
Setting the timezone on CentOS or Redhat Enterprise Linux (RHEL) is easy.Login as root either locally or remotely via SSH.
See what the current timezone is:
You should see output like this:
To change the timezone first look at what timezones are available by running the following command on the command line interface:
You should see a listing like this:
Then simply delete the current timezone:
And replace it with a symbolic link to the new timezone from /usr/share/zoneinfo. For example if your chosen zone is Pacific time:
Synchronizing time with 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.The first step is to make sure you have the ntp program installed. Do a:
If its not available type:
Once ntp is installed synchronize your computer clock with:
You are not limited to the above server. There are numerous NTP servers around the world. You can find a complete list at ntp.org.
Also keep in mind that ntp only affects the system time. The hardware clock on your server will not reflect that. So you want to set it as well so that the correct time is maintained after reboot:
ntpd
To keep your server clock automatically synchronized you can run the ntpd daemon which is installed as part of the ntp package.Edit the /etc/ntp.conf file to comment out the following lines:
#server 127.127.1.0 # local clock
#fudge 127.127.1.0 stratum 10The above two lines can sometimes prevent ntpd from properly synchronizing your clock. They are already commented out by default on CentOS/RHEL 6. But on 5.x you have to comment them out manually.
Finally type the following two commands to start the daemon and make it run automatically at boot up:
No comments:
Post a Comment