NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Accessing the battery-backed clock via userland?

Marc Tooley wrote:
> A friend's machine is gaining hundreds of seconds on a regular basis and
> I'm trying to track down what's going on. My hypothesis is that the 
> motherboard's rtc battery is dying

Maybe I misunderstand, but I don't think so.  The battery's only purpose
is to sustain the clock while the machine is powered down.  While the CPU
is running, the time of day is updated by something derived from the CPU. 
(I think that's a safe statement.  Exactly how is machine dependent.)

> ntpd refuses to correct my time because there are so many seconds lost 
> it errs on the side of caution and simply does nothing instead.

I have a Soekris box that behaved like that until I built a kernel with
the magic config options.  Is the box unusual?  Maybe you need to do the

Meanwhile, you can run the below script periodically to help ntpd. 

$ cat $(command -v Ntpdate)
#! /bin/sh
PID=$(pgrep ntpd) 
if [ -z "$PID" ]
        echo ntpd not running >&2
        /etc/rc.d/ntpd stop
SERVERS=$(grep ^server /etc/ntp.conf | awk '{print $2}')
for SERVER in $SERVERS; do 
        echo "getting date and time from ${SERVER}"
        ntpdate ${SERVER} && break
/etc/rc.d/ntpd start && printf "ntpd has pid %d\n" $(pgrep ntpd)



Home | Main Index | Thread Index | Old Index