Keeping your clock current, automatically.
Posted by Steve on Thu 7 Oct 2004 at 07:37
If you have a system which is doing something important such as handling mail, or running as firewall, it's essential that you keep the correct date and time. This allows your logs to have the correct timestamps upon them.
If you're collecting logs from multiple hosts time becomes even more important. Having the logfiles with wrong dates and times means that you'll be comparing entries out of order.
Thankfully there exists a simple protocol for keeping the dates and times of computers connected to a network in sync. It is called NTP, the Network Time Protocol.
There are several packages related to NTP in the Debian archive, probably the simplest is the client ntpdate.
Install it by running, as root, apt-get install ntpdate, and your machine will be automatically setup to sync time from the public servers which have the name pool.ntp.org.
If you wish to change them to point to an internal time server of your own you can adjust this by editting the file /etc/default/ntpdate.
I have a daily cron job that does this:
#!/bin/bash /usr/sbin/ntpdate -s /sbin/hwclock --adjust /sbin/hwclock --systohc
It seems like a good idea, especially as my Compaq server drifts by as much as 2 seconds per day. -- Adam
[ Parent | Reply to this comment ]
Better to use ntpdate on boot and then use a proper ntp daemon such as ntp-simple to carefully and slowly keep the system time correct.
See http://www.hants.lug.org.uk/cgi-bin/wiki.pl?Ntpdate
--
"It's Not Magic, It's Work"
Adam
[ Parent | Reply to this comment ]
It keeps track of how much your clock drifts and makes continuous corrections in between ntp updates.
[ Parent | Reply to this comment ]
If you don't want the configuration complexity, and don't mind sacrificing a few microseconds of accuracy, there is also OpenBSD's Openntp package. It's in the stable tree now.
[ Parent | Reply to this comment ]
But Sarge NTP hasn't been updated recently.
Some sort of mirror problem perhaps?
I'm using debian.blueyonder.co.uk
The old NTP was working fine ;)
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
The same thing happened to me too.
Running:
apt-get --print-uris upgrade -s
Shows that it it coming from Debian:
http://security.debian.org sarge/updates/main ntpdate 1:4.2.0a+stable-2sarge1
The changelog shows it is a legitimate security fix, for CAN-2005-2496. So nothing to worry about.
The only suprising thing is that I don't see an issued DSA yet...
Steve
--
[ Parent | Reply to this comment ]
I looked at the change log as well, but I now realise I read the dates as English, when they are American, TWICE, and thought what no releases since January 9th <doh> .
Vote "ISO date format" now!
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
/etc/init.d/hwclock.sh
/etc/init.d/hwclockfirst.sh
/etc/rc0.d/K25hwclock.sh
/etc/rc6.d/K25hwclock.sh
/etc/rcS.d/S50hwclock.sh
/etc/rcS.d/S18hwclockfirst.sh
[ Parent | Reply to this comment ]
Thanks for this and this great site.
[ Parent | Reply to this comment ]
thanks for the tips.
I personally opted for the "easy way" thanks to
apt-get install ntp-simple ntpdate
and just specifying the desired server in both /etc/ntp.conf and /etc/default/ntpdate
Works well IMHO ...
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
I shall look forward to reading your fully comprehensive article then ...
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
after "apt-get install ntpdate", a script, called "ntpdate", will be put in
/etc/network/if-up.d/ if you use LAN, or in /etc/ppp/ip-up.d/ if you use a modem.
Thus ntpdate can sync your system whenever you are connecting to internet
[ Parent | Reply to this comment ]
Except the only reason I ended up at this page is it was not changing the time, ran "ntpdate pool.ntp.org" and bobs your auntie
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]