ntp was Re: System clock.

Scott plug-discuss@lists.plug.phoenix.az.us
Sun, 13 Oct 2002 21:34:50 -0700 (MST)


Here is a script that I use on my system to query ntp servers and update 
the system clock.


#!/bin/sh
echo "Current date and time: `date`"
timehosts=ntp2.usno.navy.mil
if /usr/sbin/ntpdate -ub $timehosts > /dev/null; then
/sbin/hwclock --systohc
echo "Updated date and time: `date`"
fi


Since I run this via cron, I have it print the time before and after the 
update.

scott


 On Sun, 13 Oct 2002, Kevin Brown wrote:

> Bah.  Should have known this would happen.  Get pointed to the ntp site and
> noticed documentation there covering ntpdate.  Finally found out what all the
> switches were (since I don't have a man page on my system).
> 
> ntpdate -u time.nist.gov
> hwclock --systohc
> 
> -u forces ntpdate to use a port above 1024 to communicate with the timeserver
> (useful since my systems are hidden behind a NAT router.
> 
> Jon K wrote:
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > http://www.eecis.udel.edu/~mills/ntp/clock1.html
> > http://www.time.gov/timezone.cgi?Mountain/d/-7/java
> > http://tycho.usno.navy.mil/NTP/Version4/ntpd.htm
> > 
> > Take a look at these links, there are alot of servers there to sync with.
> > 
> > On Tuesday 08 October 2002 22:00, Kevin Brown wrote:
> > > I'm having a small issue with a server of mine.  I can't get it to sync to
> > > any time server to help keep it correct.  Tried the command below, what I
> > > see is:
> > >
> > > 8 Oct 21:58:27 ntpdate : no server suitable for synchronization found
> > >
> > > I can manually adjust it with date and then sync the system to the hardware
> > > clock, but it very rapidly drifts (e.g. set it now, by tommorrow night it
> > > will be 2 or 3 minutes fast and slowly increasing more).  Since I can sync
> > > my Windows machines by using Worldtime, I spent a little time trying to
> > > find an NTP server daemon for Windows that the linux machines could sync
> > > to.  Didn't find anything that would work (guess I need to improve my
> > > searching skills).
> > >
> > > I wonder if being behind a NAT router could be affecting what ntpdate is
> > > trying to find.
> > >
> > > > If you are on the net and have ntpdate installed, you can do a :
> > > >
> > > > # ntpdate timex.cs.columbia.edu
> > > >
> > > > and that will get you set against a time server.
> > > >
> > > > Afterwards, do a :
> > > >
> > > > hwclock --systohc
> > > >
> > > > And that will set the cmos clock on the motherboard so that it now has
> > > > the correct time also.
> > >
> > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> > > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> > > To subscribe, unsubscribe, or to change  you mail settings:
> > > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.2.0 (GNU/Linux)
> > 
> > iD8DBQE9o70UzFstip5OIqgRAufEAJsFRHMF6X0+ip0vHF8MyLTnQxbbtACg4Fb+
> > AKZFNhU89KmnJufCgOO0ELw=
> > =v4Dp
> > -----END PGP SIGNATURE-----
> > 
> > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> > To subscribe, unsubscribe, or to change  you mail settings:
> > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change  you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>