Weird issue configuring time

Hi!

I have recently noticed that clock on my laptop is out of sync with the actual time by about 15 minutes.
I already made a reddit post and aioeu tried to help me, but we were not quite able to fix the issue.

what is known so far:

  • for some reason the chrony.conf configuration file did not contain the fedora time pool by default, it was only configured to use _gateway (DHCP afaik) to sync time which did not work

  • changing the config and rebooting does not synchronize time and chronyc sources still only shows _gateway as a source

  • running timedatectl returns System clock synchronized: no

  • my hardware clock is also out of sync (sudo hwclock)

here is the output from timedatectl:

               Local time: Di 2024-02-06 11:00:20 CET
           Universal time: Di 2024-02-06 10:00:20 UTC
                 RTC time: Di 2024-02-06 10:00:20
                Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

and here is the output from chronyc sources

MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? _gateway                      0  10     0     -     +0ns[   +0ns] +/-    0ns

lastly, here is my (edited) chrony.conf file:

config
# These servers were defined in the installation:
server _gateway iburst
# server 0.de.pool.ntp.org
# server 1.de.pool.ntp.org
# server 2.de.pool.ntp.org
# server 3.de.pool.ntp.org

pool 2.fedora.pool.ntp.org iburst


# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).

# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Require authentication (nts or key option) for all NTP sources.
#authselectmode require

# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony

# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew

# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking

Help would be appreciated!

Removed server

the server in your conf file is invalid.
remove the line starting with _gateway and remove # in front of the de.pool servers.

running the command systemctl status systemd-timesyncd.service returns

○ systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: inactive (dead)
       Docs: man:systemd-timesyncd.service(8)

I assume this should not be the case and the service should be running.

It can’t reach a time server called _gateway. you need a valid IP or URL there.

fix the conf file first. then reload the service.

here is how my /etc/chrony.conf looks like
cat /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
pool 2.fedora.pool.ntp.org iburst

# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Require authentication (nts or key option) for all NTP sources.
#authselectmode require

# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony

# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew

# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking


make it look like

# server _gateway iburst
server 0.de.pool.ntp.org iburst
server ptbtime1.ptb.de iburst
server 1.de.pool.ntp.org iburst
server ptbtime4.ptb.de iburst

1 Like

ah, you actually got this one configured correctly, not sure why it’s timing out.
remove the invalid _gateway line and try again.

as you said i removed

server _gateway iburst

and left

pool 2.fedora.pool.ntp.org iburst

in place.

I then restarted chronyd.service and systemd-timesyncd.service. This fixed the issue.

Thank you for helping :slight_smile:
i will update my post on reddit aswell

You probably don’t want to run both chronyd and systemd-timesyncd as they will both be trying to synchronise the clock - you probably want to stick to one or the other.

3 Likes

I will keep that in mind, however i am happy that this works for now.
How would i set up my system to only use one and not the other?

Just stop the one you’re not using, and disable it if you’ve enabled it to start on boot, which it isn’t clear if you did.

The normal default for Fedora at the moment is to use chronyd for time synchronisation.

1 Like

From what I remember, systemd-timesyncd is not enabled by default in Fedora.

On a pretty virgin VM that I run, I see that service is disabled. Also, neither /etc/systemd/timesyncd.conf nor /etc/systemd/networkd.conf provide NTP servers.

I edited my post above since I confused chronyd and timesyncd but they are clearly two different services.

I suggest you reset your hardware clock to the correct UTC time. That should help with keeping times in sync after a boot.

Here’s what I did:

timedatectl set-local-rtc 0 to set the UEFI/BIOS time to UTC
timedatectl set-ntp true to enable NTP

After these, chronyd and other software and games started working correctly again.

It baffles me why these are not configured by default in an OOTB configuration for Fedora 40 :confused:

EDIT: I take it back, I constantly get errors:

may 04 18:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 04 20:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 04 22:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 05 00:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 05 02:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 05 04:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 05 06:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 05 08:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 05 10:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use
may 05 12:43:10 fedora chronyd[1431]: Could not add source 192.168.4.1 : Already in use

I have never seen a need to do that

I always set the RTC to UTC within the bios setup screens.
I then use the system settings panel to set the time zone which converts time displayed to local.
I normally only use timedatectl to confirm the settings are correct.

I’m using the KDE spin, so it might have to do something with that.

Here’s what finally fixed my settings:

Edit the first lines of /etc/chrony.conf:

# These servers were defined in the installation:  
#server _gateway iburst  
  
# Use public servers from the pool.ntp.org project.  
# Please consider joining the pool (https://www.pool.ntp.org/join.html).  
server 0.fedora.pool.ntp.org iburst  
server 1.fedora.pool.ntp.org iburst  
server 2.fedora.pool.ntp.org iburst  
server 3.fedora.pool.ntp.org iburst

Then systemctl restart chronyd

On openSUSE TW I noticed that their online time sync only applies to the OS and doesn’t immediately kick-in after a reboot. I do CMOS resets and my BIOS time is always off on fresh installs.

After doing an online time sync, I run sudo hwclock --systohc to save it to BIOS and that’s solved pretty easily.

I don’t know what Fedora does, but I never had it be an issue post-install, but seen some time flips during installing in the LiveUSB environment.

During initial setup with first boot the user selects the time zone. It is expected that the RTC in bios is already set to UTC. Until the local time zone is properly set fedora by default uses EST (New York, USA) and setting the time zone then changes it to local.