Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Feb 2005 19:52:14 +0100 (CET)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-stable@FreeBSD.ORG
Subject:   Re: Adjusting time on a secured FreeBSD machine.
Message-ID:  <200502031852.j13IqEQS051627@lurza.secnetix.de>
In-Reply-To: <200502031834.j13IYKsl050718@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Sorry for replying to myself ...

Oliver Fromme <olli@lurza.secnetix.de> wrote:
 > Adding to that, the following /bin/sh snippet should do
 > (untested!).  You have to kill ntpd before.
 > 
 > STEP=100        # number of seconds to step forward
 > while [ $STEP -gt 0 ]; do
 >         date -f %s $(( `date +%s` + 1 ))
 >         sleep 1
 >         STEP=$(( $STEP - 1 ))
 > done
 > 
 > It will take about 100 seconds to correct the clock forward
 > by another 100 seconds.  If you need to correct backwards,
 > replace "+ 1" by "- 1".  For different numbers of seconds
 > to correct, replace the 100 in the first line.
 > 
 > When you have approached the correct time sufficiently (i.e.
 > within a few seconds), restart ntpd with the -x option.

Stepping backwards with that script won't work, I guess,
because the steps will be larger than 1 second.  If you
have to step backwards, try to replace the "date" line
with these:

        NOW=`date +%s`
        sleep 0.9
        date -f %s $NOW

Again: it's untested.

Also beware that it might be a very bad idea to step the
time on a live multi-user system.  Some programs don't like
it at all.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"The scanf() function is a large and complex beast that often does
something almost but not quite entirely unlike what you desired."
        -- Chris Torek



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200502031852.j13IqEQS051627>