on 09/15/2008 11:49 AM Duncan wrote the following:
Thanasis <[EMAIL PROTECTED]> posted [EMAIL PROTECTED],
excerpted below, on  Mon, 15 Sep 2008 01:59:07 +0300:

Thanks to your guidance, I found out that I had a large "systematic
drift rate" in /etc/adjtime file. This must have been the reason why the
hwclock was set behind. So I've set the drift to zero (actually just
deleted the file and let the system create a new one) and I hope things
will be ok now. :-)

Are you on baselayout-1 still or -2 (which is still ~arch)? IDR the details on baselayout-1, but at least with -2, you can set it not to use the adjtime file at all. If you're on -2 and can't find the details yourself, post to that effect and I'll try to find them for you from this end.

Particularly if you're having trouble with the clock interrupt failing (as you mentioned you are), if you sync via NTP, that file can cause more problems than it solves, because the system keeps deciding the clock isn't working right and setting a larger adjustment, which fights what ntpd is already doing. Thus if you're running ntpd anyway, it's best to disable use of that file entirely, /especially/ if as I said your acpi or whatever is screwing it. If you're still on baselayout-1 and can't figure out how to disable adjtime, it may be worth putting a rm in /etc/ conf.d/local (make it conditional on there actually being a file to rm, so the rm doesn't error out if it's not there, and ensure the local service is in your initlevels as appropriate) for both local_start and stop, so it's regularly removed before it starts getting to be too big of a problem.

#  equery l |grep baselayout
sys-apps/baselayout-1.12.11.1

So I'm on baselayout-1.
I attach the /etc/init.d/clock which shows a local "readonly" variable that controls a "--noadjfile" option.
What does the following test do?

if ! touch /etc/adjtime 2>/dev/null ; then
               readonly="yes"
elif [[ ! -s /etc/adjtime ]] ; then
               echo "0.0 0 0.0" > /etc/adjtime
fi




#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

opts="save"

depend() {
        need localmount
}

setupopts() {
        if is_uml_sys ; then
                TBLURB="UML"
                fakeit=1
        elif is_vserver_sys ; then
                TBLURB="VServer"
                fakeit=1
        elif is_xenU_sys ; then
                TBLURB="xen"
                fakeit=1
        elif is_vz_sys ; then
                TBLURB="VZ"
                fakeit=1
        elif grep -q ' cobd$' /proc/devices ; then
                TBLURB="coLinux"
                fakeit=1
        elif [[ $(uname -m) == s390* ]] ; then
                TBLURB="s390"
                fakeit=1
        elif [[ ${CLOCK} == "UTC" ]] ; then
                myopts="--utc"
                TBLURB="UTC"
        else
                myopts="--localtime"
                TBLURB="Local Time"
        fi
        [[ ${fakeit} -eq 1 ]] && return 0

        if [[ ${readonly} == "yes" ]] ; then
                myadj="--noadjfile"
        else
                myadj="--adjust"
        fi

        if [[ ${SRM} == "yes" ]] ; then
                myopts="${myopts} --srm"
        fi
        if [[ ${ARC} == "arc" ]] ; then
                myopts="${myopts} --arc"
        fi
        myopts="${myopts} ${CLOCK_OPTS}"

        # Make sure user isn't using rc.conf anymore.
        if grep -qs ^CLOCK= /etc/rc.conf ; then
                ewarn "CLOCK should not be set in /etc/rc.conf but in 
/etc/conf.d/clock"
        fi
        # Make sure people set their timezone ... we do it here
        # even though we don't actually use the variable so that
        # people see the warning on boot.
        if [[ -z ${CDBOOT} && ${TIMEZONE-Factory} == "Factory" ]] ; then
                ewarn "Your TIMEZONE in /etc/conf.d/clock is still set to 
Factory!"
        fi
}

start() {
        local myopts=""
        local myadj=""
        local TBLURB="" fakeit=0
        local errstr=""
        local readonly="no"
        local ret=0

        if ! touch /etc/adjtime 2>/dev/null ; then
                readonly="yes"
        elif [[ ! -s /etc/adjtime ]] ; then
                echo "0.0 0 0.0" > /etc/adjtime
        fi

        setupopts

        if [[ ${fakeit} -ne 1 && -e /proc/modules && ! -e /dev/rtc ]] ; then
                modprobe rtc &> /dev/null || modprobe genrtc &> /dev/null
        fi

        ebegin "Setting system clock using the hardware clock [${TBLURB}]"
        if [[ ${fakeit} -eq 1 ]] ; then
                ret=0

        elif [[ -x /sbin/hwclock ]] ; then
                # Since hwclock always exit's with a 0, need to check its 
output.
                errstr=$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null)
                errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 
>/dev/null)"

                if [[ -n ${errstr} ]] ; then
                        ewarn "${errstr}"
                        ret=1
                else
                        ret=0
                fi
                errstr="Failed to set clock"
        else
                ret=1
                errstr="/sbin/hwclock not found"
        fi
        eend ${ret} "${errstr}" "You will need to set the clock yourself"

        return 0
}

stop() {
        # Don't tweak the hardware clock on LiveCD halt.
        [[ -n ${CDBOOT} ]] && return 0

        [[ ${CLOCK_SYSTOHC} != "yes" ]] && return 0

        local myopts=""
        local TBLURB=""
        local errstr=""
        local ret=0

        setupopts

        ebegin "Setting hardware clock using the system clock [${TBLURB}]"
        if [[ ${fakeit} -eq 1 ]] ; then
                ret=0

        elif [[ -x /sbin/hwclock ]] ; then
                errstr=$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)

                if [[ -n ${errstr} ]] ; then
                        ret=1
                else
                        ret=0
                fi
                errstr="Failed to sync clocks"
        else
                ret=1
                errstr="/sbin/hwclock not found"
        fi
        eend ${ret} "${errstr}"
}

save() {
        CLOCK_SYSTOHC="yes"
        stop
}


# vim:ts=4

Reply via email to