Raspbian Jessie Systemctl TimeDateCtl replacement for NTP
Posted: Mon Mar 27, 2017 4:00 pm
Still With the latest Raspbian Jessie images, I find that the clock source synchronisation is still being accomplished with the NTP daemon rather then with the "timedated" daemon.
Below describes the steps to remove the setup of legacy NTP configuration, and setup the new light weight “system-timedated” configuration to synchronise your system’s clock from the Internet.
First shutdown the NTP daemon process, disable the auto-start setup and deinstall the packages with the following commands on the shell prompt:
With your favourite text editor, modify the file “/etc/systemd/timesyncd.conf” to have the following contents:
You may choose the NTP sources according to your region as described with http://support.ntp.org/bin/view/Servers/NTPPoolServers.
With your favourite text editor, modify the file “/etc/rc.local” to have the following contents:
Note: The back-quote in the "systemctl" command and the "sleep" statement are very important to keep!
To finally enable the automatic start-up of the system’s clock synchronisation during boot-up using the "systemd-timesyncd" service, execute the following commands on the shell prompt:
With this approach, we leave it up to the “systemd” PID 1 daemon to start up the relevant services for date and time synchronisation from the network during boot up.
To verify its proper operation, after a little while, simply execute the following command on the shell prompt:
It shall provide an output similar to the following:
Hope this helps!
Below describes the steps to remove the setup of legacy NTP configuration, and setup the new light weight “system-timedated” configuration to synchronise your system’s clock from the Internet.
First shutdown the NTP daemon process, disable the auto-start setup and deinstall the packages with the following commands on the shell prompt:
Code: Select all
sudo systemctl stop ntp
sudo systemctl disable ntp
sudo apt-get -y remove ntp
sudo rm -f /etc/init.d/ntp
sudo rm -f /etc/default/ntp
sudo rm -f /etc/rc?.d/{S,K}??ntp
sudo rm -f /etc/ntp.conf
sudo rm -f /etc/cron.daily/ntp
sudo rm -f /var/log/ntpstats
Code: Select all
[Time]
NTP=0.europe.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org
FallbackNTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org
With your favourite text editor, modify the file “/etc/rc.local” to have the following contents:
Code: Select all
[ ! -e /var/lib/systemd/clock -a "`systemctl is-active systemd-timesyncd | grep -i active`" ] && timedatectl set-ntp 1 > /dev/null 2>&1
sleep 2
To finally enable the automatic start-up of the system’s clock synchronisation during boot-up using the "systemd-timesyncd" service, execute the following commands on the shell prompt:
Code: Select all
sudo systemctl enable systemd-timesyncd
sudo systemctl start systemd-timesyncd
sudo timedatectl set-ntp 1
To verify its proper operation, after a little while, simply execute the following command on the shell prompt:
Code: Select all
timedatectl
Code: Select all
Local time: Wed 2017-03-18 09:44:46 CET
Universal time: Wed 2017-03-18 08:44:46 UTC
RTC time: Wed 2017-03-18 08:44:46
Time zone: … (CET, +0100)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
Hope this helps!