If you need to have valid date and time on your server, you need to synchronize it with a time server as well. In order to do this in Linux (especially in CentOS), we will follow my short howto.
1. Ensure you’ve got ntp installed. Run rpm -qa | grep ntp to find out if it already exists on your system and yum install ntp if it is not present.
2. Run ntpdate. On CentOS, you will probably get this error:
[root@server ~]# ntpdate
29 Jan 09:52:54 ntpdate[8463]: no servers can be used, exiting
This means you have to include a server into your request, just like shown below.
[root@server ~]# ntpdate 0.pool.ntp.org
29 Jan 10:08:07 ntpdate[8853]: step time server 213.198.55.2 offset 676.605025 sec
This means my server had a 10-minute time diffrence with the time server. After this command my time has been adjusted.
3. Add time synchronization to your crontab and run it as often as you need.
30 * * * * /usr/sbin/ntpdate -s 0.pool.ntp.org
Will sync your clock every hour; I think is enough to perform synchronization weekly. Let’s do it.
30 10 5 * * /usr/sbin/ntpdate -s 0.pool.ntp.org
This simple guide will keep your clock synchronized. Have fun!
Tags: linux date syncronization howto, ntpdate centos, ntpdate no servers can be used, set up ntpdate, set up ntpdate linux, time sync linux
2 Responses
Mark
09|Feb|2010 1compare to ntpd, which one is better approach you think?
ntpd
admin
10|Feb|2010 2I think that this method is easier even for newbies.
Leave a reply