old-www/LDP/LG/issue72/tag/3.html

484 lines
17 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<META NAME="generator" CONTENT="lgazmail v1.4F.h">
<TITLE>The Answer Gang 72: clock problem</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"
LINK="#3366FF" VLINK="#A000A0">
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<P> <hr>
<!--startcut ======================================================= -->
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<!--endcut ========================================================= -->
<!--startcut ======================================================= -->
<P> <hr>
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
><IMG ALT="" SRC="../../gx/navbar/left.jpg"
WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0"
><A HREF="..//"
><IMG SRC="../../gx/navbar/toc.jpg" align="middle"
ALT="[ Table Of Contents ]" border="0"></A
><A HREF="../lg_answer72.html"
><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer72.html#greeting"><img align="middle"
src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
<A HREF="1.html">1</A> &nbsp;
<A HREF="2.html">2</A> &nbsp;
<A HREF="3.html">3</A> &nbsp;
<A HREF="4.html">4</A> &nbsp;
<A HREF="5.html">5</A> &nbsp;
<A HREF="6.html">6</A> &nbsp;
<A HREF="7.html">7</A> &nbsp;
<A HREF="8.html">8</A> &nbsp;
<A HREF="9.html">9</A>
</td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
ALT="[ Index of Past Answers ]" border="0"></A
><IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<!--endcut ========================================================= -->
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<center>
<H1><A NAME="answer">
<img src="../../gx/dennis/qbubble.gif" alt="(?)"
border="0" align="middle">
<font color="#B03060">The Answer Gang</font>
<img src="../../gx/dennis/bbubble.gif" alt="(!)"
border="0" align="middle">
</A></H1>
<BR>
<H4>By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and the Gang,
the Editors of Linux Gazette...
and You!
<br>Send questions (or interesting answers) to
<a href="mailto:linux-questions-only@ssc.com">linux-questions-only@ssc.com</a>
</H4>
<p><em><font color="#990000">There is no guarantee that your questions
here will <b>ever</b> be answered. Readers at confidential sites
must provide permission to publish. However, you can be published
anonymously - just let us know!
</font></em></p>
</center>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<p><hr><p>
<!-- begin 3 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
height="50" width="60" alt="(?) " border="0"
>clock problem</H3>
<p><strong>From tony
</strong></p>
<p></strong></p>
<p align="right"><strong>Answered By Thomas Adam, Ben Okopnik, Mike Orr, Mike Ellis
</strong></p>
<!-- sig -->
<P><STRONG>
I cant't seem to work this one out!!!!
On my RedHat 6.1 Linux box, my system time is set to local time and
hardware clock is set to UTC.
These times appear to be OK.
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
Why not set both to local time? This is one of the things that I idly
fiddle with occasionally, and have not seen any bad effects from either
method. Yes, the One True Unix Way is for the hardware clock to be set to
UTC... but I don't pay it much mind, especially when it gets in my way.
<IMG SRC="../../gx/dennis/smily.gif" ALT=":)"
height="24" width="20" align="middle">
Besides, if you've got a dual-boot system, poor lil' Windows gets all
confused about UTC anyway.
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Whenever I save a file, then do an ls -l, the file time shows UTC.
</STRONG></P>
<P><STRONG>
Everything else, logs, etc. show local time.
I am running ntpd, and this keeps the hardware clock OK.
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
Just remember to run
</blockQuote>
<blockQuote><CODE>
hwclock --adjust
</CODE></blockQuote>
<blockQuote>
once in a while. That way, after a couple of months, you can even turn off
"ntpd" - and your system will keep perfect time (I think that a max deviation
of one second in two or three months can be considered "perfect".) See the
discussion in the "hwclock" manpage, and read about "<TT>/etc/adjtime</TT>".
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
I have a link from <TT>/etc/localtime</TT> to <TT>/usr/share/zoneinfo.</TT>
</STRONG></P>
<P><STRONG>
I have looked up numerous web sites about the clock system, but none
have helped me.
Any pointers in the right direction would be appreciated.
</STRONG></P>
<P><STRONG>
Thanks,
Tony Ellem
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
</blockQuote>
<blockQuote>
Have you tried reading the clock-howto from the LDP
&lt;www.linuxdocs.org&gt;???
</blockQuote>
<blockQuote>
What happens if you type in the following (as root):
</blockQuote>
<blockQuote><CODE>
hwclock -W
</CODE></blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
Baldur:~# hwclock -W
unrecognized option `-W'
</blockQuote>
<blockQuote>
The short options for "hwclock" are "-[rwsavuD]", and the odd "-[AJSF]" for
DEC Alphas. What is it that you were trying to do? "hwclock -D" (debug),
maybe? I'm afraid that wouldn't be of much use: what the querent needs is a
usage methodology rather than a fix for something that's broken.
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Chris G.]
Hi Ben,
This is not a challenge, but an observation that I have made. I used to
set my real time clock to local time, but for some reason, the daylight
savings time adjustment did not automatically occur.
</STRONG></P>
<P><STRONG>
I had to set my real time clock to UTC for things to work properly. I
use the <A HREF="http://www.suse.com/">SuSE</A> 6.4 distribution (2.2.14 kernel), and maybe there exists
some sort of constraint with my distribution -- I don't know. Did you
ever hear this crazy story before?
</STRONG></P>
<P><STRONG>
Regards,
Chris Gianakopoulos
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
Actually, I'm not sure by what mechanism that _is_ supposed to happen
automatically - it never did for me whether I was using UTC or local. I
just gave up and put it in 'cron'.
<IMG SRC="../../gx/dennis/smily.gif" ALT=":)"
height="24" width="20" align="middle">
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Chris]
Hmmm. That makes sense (the cron job).
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Mike Orr]
It's supposed to be encoded in the timezone entry. It seems to be
a hit or miss thing whether it actually adjusts on the right day--
sometimes it does, sometimes it doesn't.
</blockQuote>
<blockQuote>
BTW, daylight savings time does not apply to UTC. UTC is always
sun time. But the Pacific time zone is always the same distance behind
UK time, because UK time does move with daylight savings time.
</blockQuote>
<blockQuote>
When I was in Russia in 95 or 96, it was right when Russia was
changing from the Soviet schedule for daylight savings to the western
schedule. The Soviet schedule was a few weeks earlier, because it
was early October when it happened.
</blockQuote>
<blockQuote>
Let's take a poll Monday and see how many clocks went back and how
many didn't...
</blockQuote>
<TABLE WIDTH="95%" BORDER="1" BGCOLOR="#FFFFCC"><TR><TD>
<p align="center">...............</p>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Mike]
My computer did all right.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Faber]
Interestingly, my main tower (running RH7.1) did, but my laptop (also
running RH7.1) didn't. :-?
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Chris]
OK, OK. My Linux system advanced to daylight savings time. However...
first I thought it retarded back to nondaylight... but paying closer
attention, I appeared to have advanced an additional hour. I'm trying
another timezone setting (US/Central), and I'll see what happens next
time.
</blockQuote>
<blockQuote>
P.S. My <A HREF="http://www.freebsd.org/">FreeBSD</A> machine did work all right.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Frank]
As did my Mandrake 7.2 machine - with hardware clock set to UTC.
</blockQuote>
<blockQuote>
My other machine, running Mandrake 8.0 - with hardware clock set to
local time - did not adjust though... Oh well, just meant I had to help
the computer a bit...
<IMG SRC="../../gx/dennis/smily.gif" ALT=";)"
height="24" width="20" align="middle">
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
Mine was set to do it at midnight tonight; I've just set it back a day and
did a manual adjustment. If it wasn't for youse guys, I wouldn't have had
to do <EM>all</EM> <EM>that</EM> <EM>work</EM>... I'm suffering. No, really.
<IMG SRC="../../gx/dennis/smily.gif" ALT=":)"
height="24" width="20" align="middle">
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Mike Ellis]
Mine four did OK too...
</blockQuote>
<blockQuote>
RH7.1 24x7
RH7.1 dual-boot
RH7.0 24x7
RH7.2 laptop
</blockQuote>
<blockQuote>
(my Solaris 8 box did OK as well, but somehow that seems less relevant...)
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Heather]
We weren't paying close attention here to the Linux boxen, we have SuSE 7.1
and <A HREF="http://www.debian.org/">Debian</A>, they all seemed fine. What we did notice is that the cable box
and cellphone couldn't manage to agree, and I think the Token Windows Laptop
flipped over early. Of course, we had to tweak the coffeepot on our own.
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Breen]
My clock rolled forward correctly. A side effect was that a few jobs
that run out of my crontab ran twice - I had them scheduled to run
at 0100 on Sundays. I should probably change that before next
October...
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Mike Ellis]
I'd fix it by March, or they might not run at all!
</blockQuote>
<blockQuote>
P.S. 01:00 doesn't exist on March 31st 2002 as the clocks roll from
00:59:59 to 02:00:00 when "summer time" begins again - roll on March 31st!
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Breen]
Erm -- right you are! Maybe I should just do it right now?
</blockQuote>
<blockQuote>
Thanks!
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
My clock is shafted. For some reason, my laptop thinks
that it is 29 February 1909 !?! 1909 wasn't even a
leap year!!
</STRONG></P>
<P><STRONG>
<IMG SRC="../../gx/dennis/smily.gif" ALT=":-)"
height="24" width="20" align="middle"> Don't you just love technology???
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
Especially when it comes from... &lt;cue the music&gt;
</blockQuote>
<blockQuote>
&lt;Rod Serling voice&gt; The Twilight Zone. &lt;/RSv&gt;
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/smily.gif" ALT="&lt;grin&gt;"
height="24" width="20" align="middle">
</blockQuote>
<blockQuote>
Is that what your 'top _switched_ to as a result of Daylight Wasting Time,
or is that just what your date happens to be set to randomly? And what does
your "hwclock" say? All sorts of odd things can happen with clock
settings... pardon me, <EM>will</EM> happen with clock settings if "<TT>/etc/adjtime</TT>"
is messed up. Read the "hwclock" man page (this usually leads, in one easy
step, to deleting "<TT>/etc/adjtime</TT>" and re-running "hwclock --set ...", etc.)
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
I am always setting my hardware clock, thus:
</STRONG></P>
<P><STRONG><CODE>
hwclock --set --date="/12/12/year 12:12:12"
</CODE></STRONG></P>
<P><STRONG>
(changing the appropriate values).
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
Did you read up on the "--badyear" switch in "hwclock"?
</blockQuote>
<blockQuote>
Hmm. That might contribute to the problem. The only time you want to
actually use "hwclock" to set the time is a) initially, and b) when you
figure it's been long enough that the correction factor (1 second per
&lt;interval&gt
<IMG SRC="../../gx/dennis/smily.gif" ALT=";)"
height="24" width="20" align="middle"> is sufficiently exact for your purposes. The second time is
also when you want to run "hwclock --adjust", right after you set it. The
problem is that running "hwclock --set" twiddles "<TT>/etc/adjtime</TT>" - and all
you really want in there is a correction factor for your drift rate.
Otherwise, it's best to use "date -s" - I do it all the time, since I'm
constantly shifting time zones; this does not mess with "<TT>/etc/adjtime</TT>".
</blockQuote>
<blockQuote>
In fact, here's a nifty little script that does this for me:
</blockQuote>
<p align="center">See attached <tt><a href="../misc/tag/zaptime.pl.txt">zaptime.pl.txt</a></tt></p>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
However the rate of drift on my laptop clock is
enormous. I think my BIOS clock needs fixing. The poor
things been living in Victorian times for the last
year now.....
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Ben]
The usual reason for the drift rate zooming out of sight is a CMOS battery
that's going bad. I've probably seen that happen two dozen times or more
over the years.
</blockQuote>
<p align="center">...............</p>
</TD></TR></TABLE>
<!-- end 3 -->
<P> <hr> </p>
<!-- *** BEGIN copyright *** -->
<H5 align="center">This page edited and maintained by the Editors
of <I>Linux Gazette</I>
<a href="http://www.linuxgazette.com/copying.html"
>Copyright &copy;</a> 2001
<BR>Published in issue 72 of <I>Linux Gazette</I> November 2001</H5>
<H6 ALIGN="center">HTML script maintained by
<A HREF="mailto:star@starshine.org">Heather Stern</a> of
Starshine Technical Services,
<A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H6>
<!-- *** END copyright *** -->
<!--startcut ======================================================= -->
<P> <hr>
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
><IMG ALT="" SRC="../../gx/navbar/left.jpg"
WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0"
><A HREF="..//"
><IMG SRC="../../gx/navbar/toc.jpg" align="middle"
ALT="[ Table Of Contents ]" border="0"></A
><A HREF="../lg_answer72.html"
><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer72.html#greeting"><img align="middle"
src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
<A HREF="1.html">1</A> &nbsp;
<A HREF="2.html">2</A> &nbsp;
<A HREF="3.html">3</A> &nbsp;
<A HREF="4.html">4</A> &nbsp;
<A HREF="5.html">5</A> &nbsp;
<A HREF="6.html">6</A> &nbsp;
<A HREF="7.html">7</A> &nbsp;
<A HREF="8.html">8</A> &nbsp;
<A HREF="9.html">9</A>
</td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
ALT="[ Index of Past Answers ]" border="0"></A
><IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<!--endcut ========================================================= -->
<P> <hr>
<!--startcut ======================================================= -->
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<!--endcut ========================================================= -->
</BODY></HTML>