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.

1 Like

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.