Mailing List Archive

Support open source code!


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

tlug: Strange clock problem finally solved!



--------------------------------------------------------
tlug note from Dennis McMurchy <denismcm@example.com>
--------------------------------------------------------
  Hi gang,

  I am feeling a little sheepish about this, but others may also have
run into the same problem and assumed like I did that it was due to
faulty hardware.

  The problem is this:  Not long after I bought my AST Pentium 100 in 
the fall of 1995, I began to notice that the clock was running a little
slow.  Didn't seem to matter how often I reset the time using the 'date'
command.  The time just kept slowly falling further and further behind
every time I turned off the machine.

  Finally, it was a good twenty minutes or so behind and I was getting
a little ticked at having to reset it manually every time I booted up,
so I wrote a script that would run automatically every time I logged
in as root on bootup and reset the time for me ( I include this below
for any who might be interested in the details of how to do it).  

  Well this was pretty cool, I thought.  The only trouble was that I
had to periodically edit the script to increase the number of minutes 
that it would add to the clock, because this hardware problem (bizarre
though it seemed) was slowly getting worse and worse and worse, until
finally in the latest iteration I'm adding a full 46 minutes to the 
clock every time I boot up.

  Well, I happened to be browsing through Lars Wirzenius' html version of

		Linux System Administrators' Guide 0.4
(The LaTeX source code and other machine readable formats can be found on
the Internet via anonymous ftp on sunsite.unc.edu, in the directory
/pub/Linux/docs/LDP. Also available are at least Postscript and TeX
.DVI formats. )

  In a section titled 'Hardware and Software Clocks' he notes:

	The Linux kernel keeps track of time independently from the
	hardware clock.  During the boot, Linux sets its own clock to
	the same time as the hardware clock. After this, both clocks run
	independently. Linux maintains its own clock because looking at
	the hardware is slow and complicated.  

  Well, sure enough, a little experimentation revealed that setting the
time with the 'date' command does NOT affect the hardware clock at all.
Once I reset the time in the bios setup routine, I found that this 
strange problem of losing greater and greater amounts of time has 
disappeared.

  So, if anybody needs a really cool, slightly used automatic time
setting script, here it is below.  

  At least I don't catch colds... 

Dennis McMurchy, 
Tojinmachi, Fukuoka

p.s. I just noticed that it's exactly a year to the day since I wrote this:

 # a shell script to adjust the clock, which loses forty-some minutes
# every time the machine is turned off.
# Mon May 13 22:30:49 JST 1996

if [ $(date +%M) -ge 14 ]; then     #we're coming up to the hour,so
	if [ $(date +%H) -ge 23 ]; then 
	   echo "timer: too close to midnight - better change it manually"
           exit 1
	else
	   date --set=$(( 86+10#$(date +%H%M) )) # the 10# forces no. into base ten ; the 86 is just 46 + 40 (i.e. 100 - 60) to add the hour
	fi
else
   date --set=$(( 46+10#$(date +%H%M) ))     #add forty-six minutes 
fi


-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links