LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   System Clock Always Off! (https://www.linuxquestions.org/questions/slackware-14/system-clock-always-off-4175489727/)

tb75252 12-31-2013 02:07 PM

System Clock Always Off!
 
I have installed Slackware 14.1 (64-bit) on a desktop that has an Intel DQ965GF motherboard.

The BIOS does not have a UTC setting for the hardware clock, so I was extra careful to select "Hardware clock is set to local time" while installing Slackware. I also made sure to select the correct time zone where I live.

And yet, every time that I boot up the system clock is off by +6 hours!

I am not much of a Linux expert and hope that somebody on this forum will offer some guidance towards solving this annoyance.

Thanks.

/dev/random 12-31-2013 03:33 PM

Is the BIOS battery low or dead?
Is this computer connected to the internet? if so just use NTP to correct the time.

tb75252 12-31-2013 03:46 PM

Quote:

Originally Posted by /dev/random (Post 5089806)
Is the BIOS battery low or dead?
Is this computer connected to the internet? if so just use NTP to correct the time.

Battery is good and the desktop is connected to the Internet.

KDE control module has a check mark in the box "Set date and time automatically" and the time server selected is pool.ntp.org, if that's what you are talking about.

metaschima 12-31-2013 04:52 PM

Does the output of 'date' coincide with the KDE time ?

wildwizard 12-31-2013 04:55 PM

Known problem.

If you run ntpd on recent kernels your system (BIOS) clock will be reset to UTC even though the options are turned off in the kernel config.

The only real fix is to patch the kernel config directly and then recompile it.

See patch here :-
http://www.linuxquestions.org/questi...ml#post5039950

tb75252 12-31-2013 04:57 PM

Quote:

Originally Posted by metaschima (Post 5089849)
Does the output of 'date' coincide with the KDE time ?

Yes it does. The weird thing now is that the system clock shows 04:56 AM of January 01, 2014, even though here is still 04:56 PM of December 31, 2013. So right now, the system clock is 12 hours ahead! When I originally posted the system clock was 6 hours ahead...

tb75252 12-31-2013 05:01 PM

Quote:

Originally Posted by wildwizard (Post 5089852)
Known problem.

If you run ntpd on recent kernels your system (BIOS) clock will be reset to UTC even though the options are turned off in the kernel config.

The only real fix is to patch the kernel config directly and then recompile it.

See patch here :-
http://www.linuxquestions.org/questi...ml#post5039950

Wow, patch and recompile a kernel? That looks a little bit too complicated for a newbie like me! I might just have to put up with a system clock that is off...

wildwizard 12-31-2013 05:03 PM

Until you try to use SSL and it fails as the clock is too far out.

Though you haven't stated if you are or are not running ntpd.

If you are running it what does ntpq tell you about the clock and sync.

regis_n_bits 12-31-2013 07:30 PM

Are there any other OSes installed on that box?

If not, why not just set the hardware clock to UTC (using the 'timeconfig' utility).

Z038 01-01-2014 12:20 AM

As root, what is the output of ...

Code:

# hwclock --debug ; date

Paulo2 01-01-2014 11:12 AM

I was having this problem too, even with rc.ntpd marked as executable and all KDE configurations right.

My solution was put this on rc.local
Code:

if ntpdate 200.20.186.75; then
  # set hardware clock
  hwclock -w
  echo -e "$(date)\n"
fi

That server is for Brazil BRST -3:00 (now is -2:00 since we are in daylight saving time),
I don't know if will work for every country.

Soderlund 01-01-2014 11:45 AM

Quote:

Originally Posted by Paulo2 (Post 5090190)
I was having this problem too, even with rc.ntpd marked as executable and all KDE configurations right.

My solution was put this on rc.local
Code:

if ntpdate 200.20.186.75; then
  # set hardware clock
  hwclock -w
  echo -e "$(date)\n"
fi

That server is for Brazil BRST -3:00 (now is -2:00 since we are in daylight saving time),
I don't know if will work for every country.

Have you tried to just set the date to the correct time, and then running hwclock -w? Merely setting date does not solve it, then it will go away on the next reboot like you are experiencing. You need to run hwclock -w after setting the date.

You can also get odd time problems if you multiboot and one of the distributions uses local time while the other uses UTC. If that is the case, set both to the same time.

By the way, I have an old computer that thought it was 1997 when I started it (it was 2013). Bad battery.

Paulo2 01-01-2014 12:12 PM

Quote:

Originally Posted by Soderlund (Post 5090207)
Have you tried to just set the date to the correct time, and then running hwclock -w? Merely setting date does not solve it, then it will go away on the next reboot like you are experiencing. You need to run hwclock -w after setting the date.

You can also get odd time problems if you multiboot and one of the distributions uses local time while the other uses UTC. If that is the case, set both to the same time.

By the way, I have an old computer that thought it was 1997 when I started it (it was 2013). Bad battery.

Thanks for reply :)
I have dual boot whit Slackware and XP, I have to admit that I didn't boot XP to see
if the date was right there. I didn't boot XP before the problem too, so it isn't the cause.

The command "ntpdate" retrieves time from server and writes to system clock.
"hwclock -w" writes it to the hw clock, like you said.

So far that solution worked for me, this is because I didn't investigate
the original problem with more details.
Maybe something wrong with ntpd or KDE settings, or with my hardware :D
aside battery, I changed it when the problem started.

tronayne 01-03-2014 07:19 AM

Two things you may want to do:
  • Boot XP and get into Control Panel.
  • Open Date & Time.
  • Make sure your time zone is correct (click the Time Zone tab) and remove the check from the automatically adjust clock for daylight savings. This will prevent XP from slewing the clock when you boot it after a daylight time change (Windows does that sort of thing, this is how you stop it).
  • Shut down XP and boot Slackware.
  • As root, edit /etc/ntp.conf; make your server list look like this:
Code:

#
# NTP server (list one or more) to synchronize with:
#server pool.ntp.org iburst
server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org

If you're not in the US, use the two-character code for your country.

Understand that your hardware clock and your system clock are two separate things; the hardware clock (on your motherboard) is an actual clock chip similar to your wristwatch, it's run by a battery. The system clock is software, run by interrupts in the kernel.

You want to use NTP to keep the system clock on-time. You want to use three pool servers so NTP can evaluate which of those servers is the "best" (meaning the delay, offset and jitter are the lowest available). NTP will switch between servers, selecting the best one, it will also throw out one or more periodically and select a new server if one or more become unavailable, noisy, or poor choices -- it does this without any input from you. Also, if your Internet connection goes away for a while it will synchronize to your local host until the connection comes back and resynchronize to one of the pool servers stepping the system clock back into the correct time.

Now, if NTP was running, stop it with
Code:

/etc/rc.d/rc.ntpd stop
<wait a minute or so>
/etc/rc.d/rc.ntpd start

The daemon should be running and you can exeucte
Code:

/usr/sbin/ntpq -pn
to see a display like this after about five minutes or so:
Code:

    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 127.127.1.0    .LOCL.          10 l  6d  64    0    0.000    0.000  0.000
+64.6.144.6      128.252.19.1    2 u  277 1024  37  629.042  -32.024  42.382
*216.37.64.3    132.163.4.102    2 u  401 1024  377  608.801  -27.456  38.502
+18.85.44.59    18.85.44.61      3 u  555 1024  377  614.653  -22.534  29.600

The plus sign indicates the server you're synchronized with, the asterisks indicate candidate servers, ones that may be used if the synchronized server goes away, becomes noisy or whatever makes it unsuitable.

This all supposes that your time zone is correct when NTP started. Note that /etc/rc.d/rc.ntpd has an argument that will do large correction to the system clock at boot time (at boot, time is read and initially set from the hardware clock, at shutdown, time is saved from the system clock to the hardware clock). Don't monkey with that.

There is no reason, if you turn off XP's daylight time adjustment as above to not have your hardware clock at UTC (all my servers are UTC and I have absolutely no problems with NTP keeping things on-time).

As others have described above, you can set your hardware clock from your system clock (you could also set it to the correct time UTC in the BIOS if your want to fiddle with that). Just make sure that you have the time configuration set (you may want to run [I]timeconfig/I], choosing UTC and your local time zone in console (without KDE running) or you could choose to set both clock to local time. Either way, NTP will keep your clocks synchronized. Don't monkey with time settings in KDE, it should default to what your system configuration settings are.

You may -- may! -- need to shut down, boot into BIOS and set that clock to close-to-correct wall or UTC time then boot to run level three (console, not KDE) to do these things. If you choose UTC, remember that EST in the US is UTC+5 or whatever your time zone is (it's 0812 EST, 1312 UTC right now here). If you've fiddled with settings in KDE, unfiddle 'em and let the system do its thing for you.

Hope this helps some.


All times are GMT -5. The time now is 02:03 AM.