Newsgroups: alt.os.linux.mandrake,comp.os.linux.misc,comp.protocols.time.ntp
> >> I want to use cron to run a util to check the time via the net and > >> set my clock when/if there's a difference in the hardware clock. > > > Hi Larry, This one works for me. This sets the OS time and the BIOS > > time. > > > > rdate -s clock-1.cs.cmu.edu && hwclock --systohc > > Another command that does the same job is ntpdate. And why use cron > when the only time you'll want it to run is when you connect? What I > did was create /etc/ppp/ip-up.local which contains > ntpdate ntp0.freeserve.net && hwclock --systohc > The ip-up.local script is called from /etc/ppp/ip-up which is run > whenever ppp connects to the net. cron would be of more use if you were > connected to a LAN with an NTP server.
by the way, in man hwclock it says
To see if it is on or off, use the command adjtimex —print and look at the value of "status". If the "64" bit of this number (expressed in binary) equal to 0, 11 minute mode is on. Otherwise, it is off.
and I do
$ /sbin/adjtimex -p [...] status: 64
which makes me wonder what the English of the man page is trying to say. Does "status:64" mean the 11 minute thing is on or off?
by the way, the The Clock Mini-HOWTO looked promising, but seemed not to tell us dummies exactly what to do simplewise.
I installed the ntp rpm from the 2nd mandrake 7.2 CD and notices that it doesn't put its man pages on the system, but one can dig them out of its 'doc' directory… as seen in rpm -ql ntp
Dan Jacobson
> > >> I want to use cron to run a util to check the time via the net and > > >> set my clock when/if there's a difference in the hardware clock.
> > ntpdate ntp0.freeserve.net && hwclock --systohc
A better option is to use chrony. It can both keep track of your hardware clock so that it can set the system clock accurately on bootup even if your hardware clock drifts, and go onto the net to use atomic clocks to keep your system withing afew milliseconds of accurate time.
You set it up so that it goes on net only when you are connected using the ip-up and ip-down script.
/etc/chrony.conf server x.x.x.x offline driftfile /etc/chrony.drift logdir /var/log/chrony log tracking keyfile /etc/chrony.keys commandkey 25 maxupdateskew 100.0 dumponexit dumpdir /var/log/chrony rtcfile /etc/chrony.rtc initstepslew 30 x.x.x.x
where x.x.x.x is the ip of an ntp server.
/etc/chrony.keys 25 yyyyyyyy
(this is your password to be able to carry out commands with chronyc)
/etc/ip-up.local chronyc<<EOF password yyyyyyyy online EOF /etc/ppp/ip-down chronyc<<EOF password yyyyyyyy offline EOF
And in /etc/rc.d/rc.local put
chrony -r -s
instead of the clock intialisation routines there (hwclock)
Bill Unruh
> Any suggests? I'd like to just get it to run from a command line first > then move up to a cron
You have permanent internet connection, so you can do the same I did. BTW, do you try to run "ntpdate" as user or root? ntpdate is in /usr/sbin, so it's not in ordinary user's PATH.
Do everything below as root. I created a scipt in /usr/local/bin, called "adj_time.sh":
#!/bin/sh ntpdate ntp0.freeserve.net && hwclock --systohc
Then, running "crontab -e" add the following line:
0 0 * * * /usr/local/bin/adj_time.sh
This will update your time once a day at midnight.
And, don't forget to
chmod a+x /usr/local/bin/adj_time.sh