You are not logged in.

#1 2022-11-07 19:12:58

pmatos
Member
Registered: 2017-09-03
Posts: 38

[SOLVED] NTP Service shows n/a by timedatctl

Been trying to set up everything on a new laptop using systemd available units.

Using networkd, resolved, timesyncd, etc for networking and time sync. However, I travelled to the US from EU with a different timezone and my clock just doesn't sync properly. I ended up looking things up and noticed that `sudo timedatectl status` reports `NTP service: n/a`.

This is unexpected since i expected it to notice that timesyncd is running:

 systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
     Active: active (running) since Mon 2022-11-07 18:32:41 CET; 1h 35min ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 439 (systemd-timesyn)
     Status: "Contacted time server 38.229.52.9:123 (2.arch.pool.ntp.org)."
      Tasks: 2 (limit: 76753)
     Memory: 2.2M
        CPU: 49ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─439 /usr/lib/systemd/systemd-timesyncd

Nov 07 18:32:41 butterfly systemd[1]: Starting Network Time Synchronization...
Nov 07 18:32:41 butterfly systemd[1]: Started Network Time Synchronization.
Nov 07 18:32:46 butterfly systemd-timesyncd[439]: Network configuration changed, trying to establish connection.
Nov 07 18:32:48 butterfly systemd-timesyncd[439]: Network configuration changed, trying to establish connection.
Nov 07 18:32:48 butterfly systemd-timesyncd[439]: Network configuration changed, trying to establish connection.
Nov 07 18:32:49 butterfly systemd-timesyncd[439]: Network configuration changed, trying to establish connection.
Nov 07 18:32:49 butterfly systemd-timesyncd[439]: Network configuration changed, trying to establish connection.
Nov 07 18:33:20 butterfly systemd-timesyncd[439]: Contacted time server 38.229.52.9:123 (2.arch.pool.ntp.org).
Nov 07 18:33:20 butterfly systemd-timesyncd[439]: Initial clock synchronization to Mon 2022-11-07 18:33:20.572765 CET.

Second problem I notice is that it says:

Initial clock synchronization to Mon 2022-11-07 18:33:20.572765 CET.

but hey, I am now in PST. I assumed that somehow it would also detect I am in a different timezone.

So there are two issues:
1. timedatectl doesn't show up the NTP service properly
2. timezone is not set automatically, which I expect it would be possible, probably given the assigned IP address or something.

Any suggestions on something I might be missing?

Thanks.

Last edited by pmatos (2022-11-08 04:12:53)

Offline

#2 2022-11-07 19:28:06

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 6,859

Re: [SOLVED] NTP Service shows n/a by timedatctl

What does

timedatectl

give?

What exactly do you think should be detecting your timezone automatically?

EDIT: Did you start it with

timedatectl set-ntp true 

or in some other way?

Last edited by cfr (2022-11-07 19:32:48)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2022-11-07 19:39:07

tucuxi
Member
From: Switzerland
Registered: 2020-03-08
Posts: 284

Re: [SOLVED] NTP Service shows n/a by timedatctl

NTP does not change the timezone.

Offline

#4 2022-11-08 02:04:04

pmatos
Member
Registered: 2017-09-03
Posts: 38

Re: [SOLVED] NTP Service shows n/a by timedatctl

cfr wrote:

What does

timedatectl

give?

What exactly do you think should be detecting your timezone automatically?

EDIT: Did you start it with

timedatectl set-ntp true 

or in some other way?

~ timedatectl
               Local time: Tue 2022-11-08 03:03:13 CET
           Universal time: Tue 2022-11-08 02:03:13 UTC
                 RTC time: Tue 2022-11-08 02:03:13
                Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: yes
              NTP service: n/a
          RTC in local TZ: no

Correct if I was in Europe/Berlin, but I am not. Still, I don't understand why NTP service says n/a.

Offline

#5 2022-11-08 02:05:06

pmatos
Member
Registered: 2017-09-03
Posts: 38

Re: [SOLVED] NTP Service shows n/a by timedatctl

cfr wrote:

What does

timedatectl

give?

What exactly do you think should be detecting your timezone automatically?

EDIT: Did you start it with

timedatectl set-ntp true 

or in some other way?

Also, as expected:

~ timedatectl set-ntp true
Failed to set ntp: NTP not supported

Expected because NTP service is n/a. Unexpected because systemd-timesyncd.service is running.

Offline

#6 2022-11-08 02:06:11

pmatos
Member
Registered: 2017-09-03
Posts: 38

Re: [SOLVED] NTP Service shows n/a by timedatctl

tucuxi wrote:

NTP does not change the timezone.

OK, fair enough. But then shouldn't be systemd-networkd do it?
I am pretty sure I travelled on an older laptop running ubuntu and the timezone was automatically updated. I am assuming here it was done through dhcp or something.

Offline

#7 2022-11-08 03:07:40

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 18,900

Re: [SOLVED] NTP Service shows n/a by timedatctl

pmatos wrote:
tucuxi wrote:

NTP does not change the timezone.

OK, fair enough. But then shouldn't be systemd-networkd do it?
I am pretty sure I travelled on an older laptop running ubuntu and the timezone was automatically updated. I am assuming here it was done through dhcp or something.

As stated, NTP syncs your system clock to UTC.  Ubuntu runs what, Gnome or Cinnamon? Pretty sure the auto time zone changes are a function of Gnome or a Gnome fork.  I think Plasma does it as well.  In other word Desktop Environments.  Ledd full blown Window Managers such as i3 and dwm don't generally provide that level of intrusion integration.  I don't think that is something systemd-network will do for you.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#8 2022-11-08 03:27:36

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 6,859

Re: [SOLVED] NTP Service shows n/a by timedatctl

pmatos wrote:

Also, as expected:

~ timedatectl set-ntp true
Failed to set ntp: NTP not supported

Expected because NTP service is n/a. Unexpected because systemd-timesyncd.service is running.

My suggestion was to start/enable systemd-timesyncd.service using that command as opposed to starting/enabling it with systemctl. This was based on the way the manual page for systemd-timesyncd.service says to start it:

SYSTEMD-TIMESYNCD.SERVICE(8) wrote:
timedatectl(1)'s set-ntp command may be used to enable and start, or disable and stop this service.

CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#9 2022-11-08 03:43:57

pmatos
Member
Registered: 2017-09-03
Posts: 38

Re: [SOLVED] NTP Service shows n/a by timedatctl

ewaller wrote:
pmatos wrote:
tucuxi wrote:

NTP does not change the timezone.

OK, fair enough. But then shouldn't be systemd-networkd do it?
I am pretty sure I travelled on an older laptop running ubuntu and the timezone was automatically updated. I am assuming here it was done through dhcp or something.

As stated, NTP syncs your system clock to UTC.  Ubuntu runs what, Gnome or Cinnamon? Pretty sure the auto time zone changes are a function of Gnome or a Gnome fork.  I think Plasma does it as well.  In other word Desktop Environments.  Ledd full blown Window Managers such as i3 and dwm don't generally provide that level of intrusion integration.  I don't think that is something systemd-network will do for you.

OK - then I wonder how Gnome does that cause I would like to have that on Arch / sway.

Offline

#10 2022-11-08 03:45:48

pmatos
Member
Registered: 2017-09-03
Posts: 38

Re: [SOLVED] NTP Service shows n/a by timedatctl

cfr wrote:
pmatos wrote:

Also, as expected:

~ timedatectl set-ntp true
Failed to set ntp: NTP not supported

Expected because NTP service is n/a. Unexpected because systemd-timesyncd.service is running.

My suggestion was to start/enable systemd-timesyncd.service using that command as opposed to starting/enabling it with systemctl. This was based on the way the manual page for systemd-timesyncd.service says to start it:

SYSTEMD-TIMESYNCD.SERVICE(8) wrote:
timedatectl(1)'s set-ntp command may be used to enable and start, or disable and stop this service.

Interesting, I didn't know that but trying to start the timesyncd through `set-ntp true` doesn't work because NTP service is shown as n/a.

I am starting to wonder if timedatectl support timesyncd or only some other ntp client.

Offline

#11 2022-11-08 03:49:42

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 6,859

Re: [SOLVED] NTP Service shows n/a by timedatctl

ewaller wrote:

As stated, NTP syncs your system clock to UTC.  Ubuntu runs what, Gnome or Cinnamon? Pretty sure the auto time zone changes are a function of Gnome or a Gnome fork.  I think Plasma does it as well.  In other word Desktop Environments.  Ledd full blown Window Managers such as i3 and dwm don't generally provide that level of intrusion integration.  I don't think that is something systemd-network will do for you.

As far as I know, you have to tell Plasma your time zone and there's no option for auto-detection. I haven't actively tried telling it the wrong time zone and I wouldn't be surprised if it changed the system-wide config if I change it in System Settings, but I have my doubts it would adjust it automatically. (Unless picking it up from the system configuration counts, which has nothing to do with IP detection.)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#12 2022-11-08 03:59:27

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 6,859

Re: [SOLVED] NTP Service shows n/a by timedatctl

TIMEDATECTL(1) wrote:

       

set-ntp [BOOL]

           Takes a boolean argument. Controls whether network time synchronization is active and enabled (if available). If the argument is true, this enables and starts the first existing network synchronization service. If the argument is false, then this disables and stops the known network synchronization services. The way that the list of services is built is described in systemd-timedated.service(8).

SYSTEMD-TIMEDATED.SERVICE(8)  wrote:

LIST OF NETWORK TIME SYNCHRONIZATION SERVICES
       systemd-timesyncd will look for files with a ".list" extension in ntp-units.d/ directories. Each file is parsed as a list of unit names, one per line. Empty lines and lines with comments ("#") are ignored. Files are read from /usr/lib/systemd/ntp-units.d/ and the corresponding directories under /etc/, /run/, /usr/local/lib/. Files in /etc/ override files with the same name in /run/, /usr/local/lib/, and /usr/lib/. Files in /run/ override files with the same name under /usr/. Packages should install their configuration files in /usr/lib/ (distribution packages) or /usr/local/lib/ (local installs).

       Example 1. ntp-units.d/ entry for systemd-timesyncd

           # /usr/lib/systemd/ntp-units.d/80-systemd-timesync.list
           systemd-timesyncd.service

       If the environment variable $SYSTEMD_TIMEDATED_NTP_SERVICES is set, systemd-timesyncd will parse the contents of that variable as a colon-separated list of unit names. When set, this variable overrides the file-based list described above.

       Example 2. An override that specifies that chronyd should be used if available

           SYSTEMD_TIMEDATED_NTP_SERVICES=chronyd.service:systemd-timesyncd.service

Do you have the expected in /usr/lib/systemd/ntp-units.d/? Is there anything which might be overriding that under /etc?

Last edited by cfr (2022-11-08 04:03:06)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#13 2022-11-08 04:06:29

pmatos
Member
Registered: 2017-09-03
Posts: 38

Re: [SOLVED] NTP Service shows n/a by timedatctl

cfr wrote:
ewaller wrote:

As stated, NTP syncs your system clock to UTC.  Ubuntu runs what, Gnome or Cinnamon? Pretty sure the auto time zone changes are a function of Gnome or a Gnome fork.  I think Plasma does it as well.  In other word Desktop Environments.  Ledd full blown Window Managers such as i3 and dwm don't generally provide that level of intrusion integration.  I don't think that is something systemd-network will do for you.

As far as I know, you have to tell Plasma your time zone and there's no option for auto-detection. I haven't actively tried telling it the wrong time zone and I wouldn't be surprised if it changed the system-wide config if I change it in System Settings, but I have my doubts it would adjust it automatically. (Unless picking it up from the system configuration counts, which has nothing to do with IP detection.)

In Gnome this is possible and I just confirmed in the docs: https://help.gnome.org/users/gnome-help … on.html.en and https://help.gnome.org/users/gnome-help … ne.html.en

If you have the Automatic Time Zone switch set to on, your time zone should update automatically if you have an internet connection and the location services feature is enabled.

Offline

#14 2022-11-08 04:12:25

pmatos
Member
Registered: 2017-09-03
Posts: 38

Re: [SOLVED] NTP Service shows n/a by timedatctl

cfr wrote:
SYSTEMD-TIMEDATED.SERVICE(8)  wrote:

LIST OF NETWORK TIME SYNCHRONIZATION SERVICES
       systemd-timesyncd will look for files with a ".list" extension in ntp-units.d/ directories. Each file is parsed as a list of unit names, one per line. Empty lines and lines with comments ("#") are ignored. Files are read from /usr/lib/systemd/ntp-units.d/ and the corresponding directories under /etc/, /run/, /usr/local/lib/. Files in /etc/ override files with the same name in /run/, /usr/local/lib/, and /usr/lib/. Files in /run/ override files with the same name under /usr/. Packages should install their configuration files in /usr/lib/ (distribution packages) or /usr/local/lib/ (local installs).

       Example 1. ntp-units.d/ entry for systemd-timesyncd

           # /usr/lib/systemd/ntp-units.d/80-systemd-timesync.list
           systemd-timesyncd.service

       If the environment variable $SYSTEMD_TIMEDATED_NTP_SERVICES is set, systemd-timesyncd will parse the contents of that variable as a colon-separated list of unit names. When set, this variable overrides the file-based list described above.

       Example 2. An override that specifies that chronyd should be used if available

           SYSTEMD_TIMEDATED_NTP_SERVICES=chronyd.service:systemd-timesyncd.service

Do you have the expected in /usr/lib/systemd/ntp-units.d/? Is there anything which might be overriding that under /etc?


As soon as I saw this quote, I knew my mistake. Initially I had chrony setup and had setup

           SYSTEMD_TIMEDATED_NTP_SERVICES=chronyd.service:systemd-timesyncd.service

then I removed chrony and forgot to remove that.

Now it all works as expected, as in NTP Service shows active, etc.

The only thing that it not as I want it is automatic timezone detection but it seems to a gnome location services thing, unrelated to systemd. So I will leave to another time.

Thanks for the help.

Offline

#15 2022-11-08 04:34:05

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 18,900

Re: [SOLVED] NTP Service shows n/a by timedatctl

cfr wrote:

As far as I know, you have to tell Plasma your time zone and there's no option for auto-detection. I haven't actively tried telling it the wrong time zone and I wouldn't be surprised if it changed the system-wide config if I change it in System Settings, but I have my doubts it would adjust it automatically. (Unless picking it up from the system configuration counts, which has nothing to do with IP detection.)

You may be right.  A quick search of Plasma's system settings seems to confirm it has to be changed by hand -- at least out of the box.

Last edited by ewaller (2022-11-08 04:34:20)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#16 2022-11-08 04:38:27

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 6,859

Re: [SOLVED] NTP Service shows n/a by timedatctl

For what it is worth, chrony works perfectly well without the environmental variable set because it installs a unit in /usr/lib/systemd/ntp-units.d and timedatectl picks it up fine.

This still strikes me as not working as it should. Surely the point of the environmental variable containing two (or more) services is that the system will fall back to the second (or third etc.) if the first (second etc.) isn't available. Otherwise, how is

SYSTEMD_TIMEDATED_NTP_SERVICES=chronyd.service:systemd-timesyncd.service

different from

SYSTEMD_TIMEDATED_NTP_SERVICES=chronyd.service

?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#17 2022-11-08 07:53:52

seth
Member
Registered: 2012-09-03
Posts: 33,685

Offline

Board footer

Powered by FluxBB