View previous topic :: View next topic |
Author |
Message |
ade05fr Apprentice
Joined: 18 Sep 2006 Posts: 281
|
Posted: Tue Dec 24, 2013 10:39 am Post subject: [SYSTEMD] ntpdate failed to synchronise at boot |
|
|
hie everyone
i have migrated from openRC to systemd and now i have an issue with ntpdate which i have never had with openRC.
now my time is not synchronise correctly
here is the log from journalctl
Code: |
ade05fr@wolftop ~ $ sudo systemctl status ntpdate.service
ntpdate.service - Set time via NTP using ntpdate
Loaded: loaded (/usr/lib64/systemd/system/ntpdate.service; enabled)
Drop-In: /etc/systemd/system/ntpdate.service.d
└─00gentoo.conf
Active: failed (Result: exit-code) since mar. 2013-12-24 10:26:41 CET; 8min ago
Process: 2033 ExecStart=/usr/sbin/ntpdate -b -u $SERVER (code=exited, status=1/FAILURE)
Main PID: 2033 (code=exited, status=1/FAILURE)
CGroup: /system.slice/ntpdate.service
déc. 24 10:26:41 wolftop ntpdate[2033]: Error resolving 0.gentoo.pool.ntp.org: System error (-11)
déc. 24 10:26:41 wolftop ntpdate[2033]: 24 Dec 10:26:41 ntpdate[2033]: Can't find host 0.gentoo.pool.ntp.org: System error (-11)
déc. 24 10:26:41 wolftop ntpdate[2033]: Error resolving 1.gentoo.pool.ntp.org: System error (-11)
déc. 24 10:26:41 wolftop ntpdate[2033]: 24 Dec 10:26:41 ntpdate[2033]: Can't find host 1.gentoo.pool.ntp.org: System error (-11)
déc. 24 10:26:41 wolftop ntpdate[2033]: Error resolving 2.gentoo.pool.ntp.org: System error (-11)
déc. 24 10:26:41 wolftop systemd[1]: ntpdate.service: main process exited, code=exited, status=1/FAILURE
déc. 24 10:26:41 wolftop systemd[1]: Failed to start Set time via NTP using ntpdate.
déc. 24 10:26:41 wolftop systemd[1]: Unit ntpdate.service entered failed state.
|
the file localtime from /etc is correctly set
I have modifier the dhcpcd service and ntpdate service in the after and before clause like that
Code: |
cat /usr/lib/systemd/system/ntpdate.service
[Unit]
Description=Set time via NTP using ntpdate
After=network.target nss-lookup.target dhcpcd.service
Before=time-sync.target
Wants=time-sync.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/ntpdate -b -u $SERVER
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
|
Code: |
cat /usr/lib/systemd/system/dhcpcd.service
[Unit]
Description=Lightweight DHCP client daemon
Wants=network.target
Before=network.target ntpdate.service
[Service]
ExecStart=/sbin/dhcpcd -q --nobackground
[Install]
WantedBy=multi-user.target
|
even though the synchronization is not ok at boot sequence
FYI if i run manually in a gnome-terminal the command
Code: | sudo systemctl start ntpdate.service |
then the time is correctly modified
I think that the problem is only related to a dependance between dhcp and the network connection.
can someone help me ?
thanks _________________ [LAPTOP]
DELL Inspiron 5110
i5-2450M CPU @ 2.50GHz
[LINUX-GENTOO]
Gentoo 2018-0
kernel 5.0.6
gnome 3.30 |
|
Back to top |
|
|
Kompi Apprentice
Joined: 05 Oct 2002 Posts: 252 Location: Germany
|
Posted: Mon Dec 30, 2013 11:51 am Post subject: |
|
|
I think you are right, the error messages from ntpdate suggest that it cannot resolve host names via DNS, which indicates that the network is not yet up when ntpdate is started.
I think the problem is ntpdate.service is started as soon as dhcpcd is started. However, dhcpcd will need some time to acquire the IP-address, DNS nameserver IP etc.
Try modifying the [Service] section of your dhcpcd.service the following way:
Code: | [Service]
Type=forking
ExecStart=/sbin/dhcpcd -q --background --waitip |
The --waitip flag tells dhcpcd to fork not before an IP address has been acquired. The "type=forking" in combination with --background instead of --nobackground will change this to a forking daemon. This should have the effect that any service with "After=dhcpcd.service" should wait until dhcpcd forks, i.e. the IP address is assigned. |
|
Back to top |
|
|
thawn n00b
Joined: 31 Aug 2004 Posts: 41
|
Posted: Mon Jan 13, 2014 9:49 pm Post subject: solution |
|
|
I found the solution here
basically. you need to enable the NetworkManager.service and the NetworkManager-wait-online.service, otherwise the network.target is reached before the network is actually up (read the explanation in the link above for more details) so do:
Code: | systemctl enable NetworkManager.service
systemctl enable NetworkManager-wait-online.service
|
and you should be all set. |
|
Back to top |
|
|
666threesixes666 Veteran
Joined: 31 May 2011 Posts: 1248 Location: 42.68n 85.41w
|
Posted: Mon Jan 13, 2014 11:20 pm Post subject: |
|
|
bleh i need the answer for openrc too for networkmanager |
|
Back to top |
|
|
nixphoeni Retired Dev
Joined: 23 Oct 2004 Posts: 11
|
Posted: Sun Oct 26, 2014 1:16 am Post subject: |
|
|
I've been wondering this for a while...it doesn't seem to be enough to enable NetworkManager-wait-online. Drop the following into /etc/systemd/system/ntpdate.service.d/10network-online.conf:
Code: | [Unit]
After=network-online.target
Wants=network-online.target |
This starts ntpdate after the network comes online at boot. |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
|