[kde-linux] KDE Clock Applet Shows Wrong Time
Thomas Ronayne
trona at ameritech.net
Wed Dec 28 13:10:44 UTC 2005
This sounds like a couple of things -- the hint is dual booting with XP.
Winders does far too many strange things, one of which is that you set
your clock to your local time zone (not GMT unless, of course, you
happen to live in the GMT time zone!). Linux, in that environment, will
need to know that the time is set to the local time zone so it doesn't
do the automagic offset; I live in the US EST, five hours difference
from GMT, but my hardware clock is set to EST because I occasionally
have to hold my nose and boot XP to do things that just aren't available
for Linux (yet!). If you're going to use XP, you have to make your Linux
environment adhere to XP's strange ideas about timezones or you'll have
a mess.
Here's a suggestion: get NTP working (and your KDE clock display will be
what you expect it to be).
First off, you should have a utility timeconfig (it may be a link in
/usr/share/zoneinfo to /usr/sbin/timeconfig). If you run that, you will
be able to set your Linux timezone correctly, bearing in mind that XP
already set your hardware clock to something (and you really need to
know what that "something" is -- maybe you should boot XP and check the
settings before doing anything else; make sure the time zone is set
correctly and use the XP utility that syncs with "network time" to set
it and the hardware clock to the right time in your timezone). After you
do that, boot Linux and run the timeconfig utility to set the Linux side
of the world to the same timezone as XP. It should ask you whether the
hardware clock is set to Coordinated Universal Time (UTC/GMT) and you
should say no, the hardware clock is set to local time (because that's
what XP does). It will give you a list of timezones, pick the right one
for your local timezone. That will get Linux in the same timezone XP is
in. And, oh, yeah, you have to be logged in as root to do this and you
probably want to do it without starting KDE. Once you've done this, you
can dual boot Linux and XP without having to fool around with the clock
(exception: be sure to disable XP's automatic daylight saving time!).
Now, with your internet connection active, execute this:
/usr/sbin/ntpdate -v ntp-1.mcs.anl.gov ntp-2.mcs.anl.gov
That will set the clock to the time in your timezone and, once you've
done this, KDE will probably display the correct time for you (if you
haven't messed around with the timezones in the KDE clock configure,
that is).
Setting up NTP is not as difficult as it seems.
Create a file, drift, in /etc/ntp.conf with 0.0 in it.
Create a file, /etc/ntp.conf like this (you probably have a sample file
that contains most of the following, just merge these with what you have):
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
driftfile /etc/ntp/drift
multicastclient # listen on default 224.0.1.1
broadcastdelay 0.008
restrict 127.0.0.1
The above are all you need.
My system uses /etc/rc.d files to start and stop services. This is the
/etc/rc.d/rc.ntpd file I use to start NTP at boot:
#!/bin/sh
#
# start the Network Time Protocol
#
if [ ${1} = "start" ]
then
# set the clock from a public server
echo "Setting clock from ntp-1.mcs.anl.gov..."
/usr/sbin/ntpdate -v ntp-1.mcs.anl.gov ntp-2.mcs.anl.gov
sleep 2
echo "Starting Network Time Protocol daemon..."
>/tmp/ntp.log
/usr/sbin/ntpd -l /tmp/ntp.log
elif [ ${1} = "stop" ]
then
echo "Stopping Network Time Protocol daemon..."
pid=`/bin/ps -e | /usr/bin/grep ntp |\
/usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
if [ "${pid}" != '' ]
then
kill ${pid}
fi
fi
Make the above executable (chmod 755 /etc/rc.d/rc.ntpd).
And there is a section in /etc/rc.d/rc.local that executes the above:
# Put any local setup commands in here:
#
# Start the NTP daemon
#
if [ -x /etc/rc.d/rc.ntpd ]
then
/etc/rc.d/rc.ntpd start
fi
If your system doesn't use /etc/rc.d, you'll need to put the above where
your system does start and stop things and name rc.ntpd something
differently; e.g., S99NTPD or whatever your box uses.
Using "/usr/sbin/ntpdate -v ntp-1.mcs.anl.gov ntp-2.mcs.anl.gov" to
initially set the clock assures that the NTP daemon will be able to sync
-- if your clock is too far off (as yours is) the daemon will not sync
and getting your machine into the right timezone assures that ntpdate
and ntpd can do their collective things properly.
Periodically check log file -- /tmp/ntp.log -- and see what's going on.
You should see entries like this after ntpd has been running for an hour
or so:
26 Dec 11:31:32 ntpd[5186]: logging to file /tmp/ntp.log
26 Dec 11:31:32 ntpd[5186]: ntpd 4.2.0 at 1.1161-r Mon Mar 29 22:23:49
PST 2004 (1)
26 Dec 11:31:32 ntpd[5186]: precision = 1.000 usec
26 Dec 11:31:32 ntpd[5186]: kernel time sync status 0040
26 Dec 11:31:34 ntpd[5186]: frequency initialized -2.572 PPM from
/etc/ntp/drift
26 Dec 11:34:48 ntpd[5186]: synchronized to LOCAL(0), stratum=10
26 Dec 11:34:48 ntpd[5186]: kernel time sync disabled 0041
26 Dec 11:35:53 ntpd[5186]: kernel time sync enabled 0001
26 Dec 11:40:09 ntpd[5186]: synchronized to 72.3.133.147, stratum=2
26 Dec 12:03:49 ntpd[5186]: time reset -0.321047 s
26 Dec 12:08:03 ntpd[5186]: synchronized to LOCAL(0), stratum=10
26 Dec 12:13:25 ntpd[5186]: synchronized to 72.3.133.147, stratum=2
27 Dec 17:38:18 ntpd[5186]: synchronized to 192.83.249.31, stratum=2
Those occasional "synchronized to LOCAL(0), stratum=10" messages? That's
what happens when your internet connection goes away for a short time
and when a server you were synced to goes away (the use of the pool
servers does that every so often).
Hope this helps some.
More information about the kde-linux
mailing list