Here we can find the steps that we need to follow for configure NTP service in our Raspberry Pi running Raspbian or RaspberryOS.

Although ntpd is discontinued and nowadays there’re better options like openntp or chrony, nptd is the easyest service to configure time synchronization in our systems… let’s go!

sudo apt-get install ntp

Next we should configure our time zone through timedatectl command, which will  link (symlink) with /etc/localtime.

sudo timedatectl set-timezone Europe/Madrid

We can chek that the changes were made:

sudo timedatectl status

Now we should define ntp server in config file.

vi /etc/ntp.conf
...
# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
pool 0.debian.pool.ntp.org iburst
pool 1.debian.pool.ntp.org iburst
pool 2.debian.pool.ntp.org iburst
pool 3.debian.pool.ntp.org iburst
...

and we will ensure that the driftfile is propertly configured:

driftfile /var/lib/ntp/ntp.drift

This file is the responsible for managing system time deviations.

Arrived this point, we can synchronize our systema time manually:

ntpd -qg

System will return the current time configuration:

[pi@raspberry ~]# ntpd -qg
ntpd: time set +1360794632.505991s
[pi@raspberry ~]# date
Wed Feb 13 23:47:48 CET 2013

And finally we’ll configure ntpd service for start when system boots and start it manually this time:

systemctl enable ntpd
systemctl start ntpd

And that’s all!!

I hope this article will be useful for you.

See you!