LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-17-2008, 11:02 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
How can I sync my server's time with a certain date server and have it check itself


How can I sync my server's time with a certain date server and have it check itself (by going to that server to see what the right time is) every so often automatically?
 
Old 07-17-2008, 11:20 PM   #2
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
apropos ntp
 
Old 07-17-2008, 11:41 PM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Two common approaches:

1) update only periodically
2) update continuously

If you only care about close enough, approach 1 will be sufficient, perhaps once or twice per day, or as you see fit. You can use NTP utilities such as ntpdate to synchronize your clock with a remote server. This is essentially a one shot update, and you repeat (via cron, at boot time, or other mechanism) as necessary or desired. The problem with this approach is that is that time jumps forward or backwards, in irregular amounts of time when you sync.

If you need more precise time constantly, approach 2 is necessary, where you run an NTP protocol daemon that constantly adjusts the kernel's notion of a time increment, keeping your system's time very accurate. One commonly used NTP daemon is ntpd.

In either case, you select one or more NTP servers near you (in terms of fewest network hops and minimal latency), and configure your system to synchronize what those systems. Many sites ask that you send an email indicating your desire to use their time services, so check the site policy.

The highly detailed http://www.ntp.org/ site explains as much as you'd like to know. Or use Wikipedia or other resource for more information.
 
Old 07-18-2008, 05:31 PM   #4
kenoshi
Member
 
Registered: Sep 2007
Location: SF Bay Area, CA
Distribution: CentOS, SLES 10+, RHEL 3+, Debian Sarge
Posts: 159

Rep: Reputation: 32
Its pretty simple (assuming CentOS/Redhat). Open a shell prompt as root and type the following:

1. chkconfig ntpd on
This turns on ntpd for runlevel 2345

2. ntpdate us.pool.ntp.org
This initializes your clock to the US pool. Please use appropriate country pool, go to www.ntp.org as Mr C suggested.

3. service ntpd start
This starts the ntpd service

4. hwclock --systohc
This syncs the hardware clock to current time

The default settings in /etc/ntp.conf should work for most people. For more information, just man ntp.conf. Mr C has some good advice in his reply if you want to select better servers than the default.

Hope this helps.
 
Old 07-18-2008, 05:54 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
I'd forgotten about the pool. The last couple of times I'd tested out pool server latencies, it was suboptimal, and even today in the S.F. Bay Area, I still find latencies to be 60-90ms from pool servers. Compared this to the 10-16ms I get when using closer NTP servers.

So, check your pool server time latencies by ping or tracerouting:

ping 0.us.pool.ntp.org
ping 1.us.pool.ntp.org
ping 2.us.pool.ntp.org
ping 3.us.pool.ntp.org

and choose either the pool servers or closer (and of course equally reliable) servers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set and sync system time with time server?? servnov Linux - Newbie 6 12-03-2013 07:55 PM
Sync windows 2000 server time with Linux server johnbeskie Linux - Enterprise 2 11-03-2007 04:25 AM
sync time & date slack66 Slackware 3 04-15-2007 11:45 AM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration