Laptop time setting is way off

Hi
I upgraded my Asus i3 laptop from 13.1 to 13.2. I use KDE. Other than a minor VPN DNS issue, the upgrade went well.
But now I have noticed that three times in the last few weeks the time on the laptop is WAY off…two or three days in the future. I am using pool.ntp.org for timesync and it seems to sync fine and hold time as long as I’m using it. But sometime when it is hibernating, it completely loses time. It is now Tue Dec 9th and when I woke up my laptop tonight, it thought it was Thursday Dec 11th.

Has anyone seen anything like this?

Matt

Here’s some more info. Got this from ntp.conf

8 Dec 17:34:40 ntpd[27600]: Deleting interface #12 wlan0, fe80::1e4b:d6ff:fe55:af92#123, interface stats: received=0, sent=0, dropped=0, active_time=75182 secs
8 Dec 17:34:40 ntpd[27600]: Deleting interface #11 wlan0, 192.168.0.67#123, interface stats: received=87, sent=87, dropped=0, active_time=75182 secs
8 Dec 17:34:40 ntpd[27600]: 38.229.71.1 interface 192.168.0.67 -> (none)
8 Dec 17:34:40 ntpd[27600]: peers refreshed
11 Dec 16:52:22 ntpd[27600]: Listen normally on 13 wlan0 fe80::1e4b:d6ff:fe55:af92 UDP 123
11 Dec 16:52:22 ntpd[27600]: peers refreshed
11 Dec 16:52:22 ntpd[27600]: new interface(s) found: waking up resolver
11 Dec 16:52:26 ntpd[27600]: Listen normally on 14 wlan0 192.168.0.67 UDP 123
11 Dec 16:52:26 ntpd[27600]: peers refreshed
11 Dec 16:52:26 ntpd[27600]: new interface(s) found: waking up resolver

For some reason it jumped from 8 Dec to 11 Dec

On 2014-12-10 00:36, mschlawin wrote:

> But now I have noticed that three times in the last few weeks the time
> on the laptop is WAY off…two or three days in the future. I am using
> pool.ntp.org for timesync and it seems to sync fine and hold time as
> long as I’m using it. But sometime when it is hibernating, it
> completely loses time.

The trick is to restart ntpd automatically after hibernation. I’m unsure
if 13.2 has pm-uitils or not.

IMO, ntpd can not work right in a laptop, instead you should call “rcntp
ntptimeset” as an hourly cronjob.

> Has anyone seen anything like this?

Does your machine double boot to another OS?


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

I can try running ntpd as an hour cron job, but I have been running opensuse for years and years on laptops and have never had this problem

Yes, this machine does dual boot with Win 7. Why do you ask? Is that an issue?

Thanks for the help!

Matt

On 2014-12-10 02:56, mschlawin wrote:
>
> I can try running ntpd as an hour cron job, but I have been running
> opensuse for years and years on laptops and have never had this problem

You may not notice, but ntpd doesn’t work right unless it is running for
many hours, without interruption. ntpd not only reads the clock from
internet and sets the local clock with that information, but it also
adjusts the speed of the local clock so that it is in sync with what it
considers “perfect time reference”. This needs time to happen, and
interruptions messes it.

At least, you have to restart it on restore from hibernation. If the
running ntpd finds that the clock has shifted, while it was sleeping,
beyond certain amount of time, it quits. A preventive restart avoids this.

> Yes, this machine does dual boot with Win 7. Why do you ask? Is that
> an issue?

Yes, it is.

For many reasons.

Any other operating system may have its own ideas about time. If the
clock is some seconds off the mark, the ntpd daemon on Linux (when
booted) has to correct and compensate for what it considers a drift from
an unknown source.

But most importantly, typically Windows wants the cmos clock (the
battery backed clock) running on local time, while Linux wants it on
“utc” time. This causes problems, often meaning that on each boot the
time shifts “hours”. And trying to compensate causes further problems.
Difficult to explain. Devs have been trying for years to get the
compensation right, and finally they gave up.

Best thing it to convince Windows to also use utc for the cmos
reference, and same on Linux, so that they agree.

In Windows, apply the regedit change as explained here:
SDB:Configuring the clock


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Thanks for the advice. It looks like 13.2 does not have a rcnttpd any more. But, service ntpd start does work.

A friend of mine also suggested trying to put this:

#!/bin/bash
if “$1” = “resume” -o “$1” = “thaw” ]; then
service ntpd stop
ntpdate pool.ntp.org
service ntpd start
fi

into /etc/pm/sleep.d

I’ll try a few things to see if I can get it fixed. I just wish it worked on it’s own without having to kludge it.

Thanks for the help.

Matt

On 2014-12-11 02:36, mschlawin wrote:
>
> Thanks for the advice. It looks like 13.2 does not have a rcnttpd any
> more. But, service ntpd start does work.

It does :slight_smile:

oS-13-2:~ # rcntpd status
ntpd.service - NTP Server Daemon
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled)
Active: inactive (dead)
Docs: man:ntpd(1)

oS-13-2:~ #

> A friend of mine also suggested trying to put this:
>
> #!/bin/bash
> if “$1” = “resume” -o “$1” = “thaw” ]; then
> service ntpd stop
> ntpdate pool.ntp.org
> service ntpd start
> fi
>
> into /etc/pm/sleep.d

Yes, absolutely, I have something like that. In 13.1. In 13.2 I said there were talks of removing pm-utils support, so I have my doubts what to do.

Ok, I have this in my system - it needs some reworking, though:

/etc/pm/sleep.d/90clock


#!/bin/bash

.. /usr/lib/pm-utils/functions

#CER: Modified. Use systemd. Do not touch hwclock.

#CER: Another posibility would be to simply call rcntp timeset on resume. Not sure about it.
# But a restart causes it to reevaluate the round-robin servers.

suspend_clock() {
echo "I'm going see if I have to stop the ntp service"
rc=0
if  ! -f /var/run/pm-ntpd.lock ]; then
echo "Touching flag, and stopping ntp"
touch /var/run/pm-ntpd.lock
systemctl stop ntp.service
#/etc/init.d/ntp stop
else
echo "Flag file exists, skipping stopping ntp"
fi

#/sbin/hwclock --systohc >/dev/null 2>&1 0<&1
return $?
}


resume_clock() {
#/sbin/hwclock --hctosys >/dev/null 2>&1 0<&1
#rc=$?
rc=0

echo "I'm going to start the ntp service, in background"

# Bring back ntpd _after_ NetworkManager and such come back...
(   touch /var/run/pm-ntpd.lock ;
# pings the router. If it responds, it exits inmediately, meaning there is network. If it doesn't, it retries 8 times.
# It only writes about failures. No need to check output, I only want to wait for network...
fping -u -r 8 192.168.1.1 ;
systemctl start ntp.service ;

rm -f /var/run/pm-ntpd.lock
) &
return $rc
}


case "$1" in
hibernate|suspend)
suspend_clock
;;
thaw|resume)
resume_clock
;;
*)
;;
esac

exit $?

> I’ll try a few things to see if I can get it fixed. I just wish it
> worked on it’s own without having to kludge it.

:slight_smile:

Probably it works for most people. Maybe some observe more and see the problems :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)