Page 1 of 1

[SOLVED] Hardware clock

PostPosted: Apr 22nd, '24, 12:39
by morgano
I got confused by time jump in system journal log during boot in one computer i maintain:

Code: Select all
   apr 22 11:18:58 aspire7-kajsa systemd-networkd[809]:     ** dont mind it said on this line, just see the time stamp **
   apr 22 11:39:18 aspire7-kajsa systemd-timesyncd[997]: System clock time unset or jumped backwards, restored from recorded timestamp: Mon 2024-04-22 11:39:18 CEST
   apr 22 11:39:18 aspire7-kajsa systemd-timesyncd[997]: The system is configured to read the RTC time in the local time zone. This mode cannot be fully supported. All system time to RTC updates are disabled.


So it seems that in beginning of booting system use hardware clock which is 21 minutes behind, then something suddenly realise it is wrong and correct it from then on.
As the last cited journal line say, should we change our installer so it always sets up systems to UTC instead (or what is the opposite of local time here)?

I understand the difference may confuse some programs
Code: Select all
  [kajsa@aspire7-kajsa ~]$ date ; sudo hwclock -r
  mån 22 apr 2024 11:53:23 CEST
  2024-04-22 11:32:37.253448+02:00



For now, i set hwclock to system time:
Code: Select all
   [kajsa@aspire7-kajsa ~]$ sudo hwclock -w


And now time corresponds

Code: Select all
   [kajsa@aspire7-kajsa ~]$ date ; sudo hwclock -r
   mån 22 apr 2024 12:25:11 CEST
   2024-04-22 12:25:11.374088+02:00


But apparently it may drift off far. How to avoid that?

Re: Hardware clock

PostPosted: Apr 22nd, '24, 15:02
by Germ
I used to set the system to local time but the last couple of years I've been using UTC. Although, I've never had your problem either before or after the change.

Re: Hardware clock

PostPosted: Apr 22nd, '24, 16:10
by doktor5000
Best post the output of
Code: Select all
timedatectl
, and best don't use hwclock directly.
Also please mention whether this is a dual-boot system, it's relevant in what timezone the local clock is stored to the realtime clock.

Re: Hardware clock

PostPosted: Apr 22nd, '24, 23:24
by morgano
Code: Select all
[kajsa@aspire7-kajsa ~]$ timedatectl
               Local time: mån 2024-04-22 23:18:38 CEST
           Universal time: mån 2024-04-22 21:18:38 UTC
                 RTC time: mån 2024-04-22 23:18:39
                Time zone: Europe/Stockholm (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.


This machine is effectively a Mageia 9 only system since previous alternate boot MSW10 killed itself and user have no need to have it fixed :)

Re: Hardware clock

PostPosted: Apr 23rd, '24, 18:14
by doktor5000
If it's not dualboot then follow the advice
Code: Select all
timedatectl set-local-rtc 0

Also check the option --adjust-system-clock which should only be necessary once.

If the time drift from your logs still happens then it's probably a good time to replace the CMOS battery of your mainboard. ;)

Re: Hardware clock

PostPosted: Apr 24th, '24, 22:48
by morgano
Thank you :)
Code: Select all
[kajsa@aspire7-kajsa ~]$ timedatectl set-local-rtc 0 --adjust-system-clock
[kajsa@aspire7-kajsa ~]$ timedatectl
               Local time: ons 2024-04-24 22:41:16 CEST
           Universal time: ons 2024-04-24 20:41:16 UTC
                 RTC time: ons 2024-04-24 22:41:18
                Time zone: Europe/Stockholm (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

The clock battery yes... Strange there generally seem to lack measurement facility for clock batteries on computers.

Re: [SOLVED] Hardware clock

PostPosted: Apr 25th, '24, 08:40
by benmc
morgano wrote:should we change our installer so it always sets up systems to UTC instead (or what is the opposite of local time here)?


Installer does offer local or UTC during install.
It pays to check that it is actually set as requested though, after install is completed.

Re: [SOLVED] Hardware clock

PostPosted: Apr 25th, '24, 11:04
by morgano
Yes i remember now. Problem is that most users do not know enough to choose. Maybe there should be some short guiding text, and what to search in internet for.

https://wiki.archlinux.org/title/System ... le_systems
https://ubuntuhandbook.org/index.php/20 ... ot-ubuntu/

Optimally all systems should be set to use hardware clock as UTC; if another system use it another way, user should adjust that.