Open main menu

DAVE Developer's Wiki β

Changes

DESK-MX-L-AN-0005: How to synchronize date/time

6,419 bytes added, 12:19, 22 February 2022
Created page with "{{ImportantMessage|text=This application note has been validated using the '''kit version''' in the History table.}} ==History== {| class="wikitable" border="1" !Version !Da..."
{{ImportantMessage|text=This application note has been validated using the '''kit version''' in the History table.}}

==History==

{| class="wikitable" border="1"
!Version
!Date
!Development Kit version
|-
| 1.0.0
| Feb 2022
|[[DESK-MX6UL-L/General/Release_Notes#DESK-MX6L-L_1.0.0|DESK-MX6L-L 1.0.0]]
[[DESK-MX6UL-L/General/Release_Notes#DESK-MX6UL-L_1.0.1|DESK-MX6UL-L 1.0.1]]
|-
|}

==Introduction==
System date and time can be easily kept synchronized using the NTP services available on Internet.

To set the date, you need to set your timezone information and to activate the NTP protocol in order for your system to synchronize with NTP servers.

If the ntp package is not present in the root file system, it is possible to install it using the standard <code>dnf</code> tool as described [[DESK-MX6UL-AN-0003:_Package_Management_with_Yocto_and_DNF |here]]:

<pre class="board-terminal">
root@desk-mx6:~# dnf install ntp
desk-mx6l-cortexa9hf_neon 2.0 MB/s | 3.1 MB 00:01
Last metadata expiration check: 0:00:08 ago on Tue Mar 31 09:05:08 2020.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ntp cortexa9hf_neon 4.2.8p11-r0 cortexa9hf 322 k
Installing dependencies:
ntp-tickadj cortexa9hf_neon 4.2.8p11-r0 cortexa9hf 8.4 k

Transaction Summary
================================================================================
Install 2 Packages

Total download size: 330 k
Installed size: 783 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): ntp-tickadj-4.2.8p11-r0.cortexa9hf_neon. 109 kB/s | 8.4 kB 00:00
(2/2): ntp-4.2.8p11-r0.cortexa9hf_neon.rpm 1.1 MB/s | 322 kB 00:00
--------------------------------------------------------------------------------
Total 1.0 MB/s | 330 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : ntp-tickadj-4.2.8p11-r0.cortexa9hf_neon 1/2
Running scriptlet: ntp-4.2.8p11-r0.cortexa9hf_neon 2/2
Running useradd commands...
NOTE: ntp: Performing useradd with [ --system --home-dir /var/lib/ntp --no-create-home --shell /bin/false --user-group ntp]
Installing : ntp-4.2.8p11-r0.cortexa9hf_neon 2/2
Running scriptlet: ntp-4.2.8p11-r0.cortexa9hf_neon 2/2
update-alternatives: Linking /usr/sbin/ntpd to /usr/sbin/ntpd.ntp
Created symlink /etc/systemd/system/multi-user.target.wants/ntpd.service \u2192 /lib/systemd/system/ntpd.service.
Verifying : ntp-4.2.8p11-r0.cortexa9hf_neon 1/2
Verifying : ntp-tickadj-4.2.8p11-r0.cortexa9hf_neon 2/2

Installed:
ntp.cortexa9hf_neon 4.2.8p11-r0 ntp-tickadj.cortexa9hf_neon 4.2.8p11-r0

Complete!
root@desk-mx6:~#
</pre>

Then the <code>/etc/ntp.conf</code> file has to be modified according to the ntp server pool used for time synchronization, for example in Italy:

<pre>
server 0.it.pool.ntp.org
server 1.it.pool.ntp.org
server 2.it.pool.ntp.org
server 3.it.pool.ntp.org
</pre>

=== Timezone ===
Be sure you are properly configured for your ''locatimezone''. In order to consult your current timezone on Linux, you can run the timedatectl command.

<pre class="board-terminal">
root@desk-mx6:~# timedatectl
Local time: Tue 2022-02-22 12:12:22 UTC
Universal time: Tue 2022-02-22 12:12:22 UTC
RTC time: Tue 2022-02-22 12:12:22
Time zone: Universal (UTC, +0000)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
root@desk-mx6:~#
</pre>

For that purpose, you may have to install the proper <code>tzdata</code> package, for example:

<pre class="board-terminal">
root@desk-mx6:~# dnf install tzdata-europe
desk-mx6l-noarch 30 kB/s | 155 kB 00:05
Last metadata expiration check: 0:00:00 ago on Tue Feb 22 12:14:45 2022.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
tzdata-europe noarch 2018f-r0 noarch 25 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 25 k
Installed size: 132 k
Is this ok [y/N]: y
Downloading Packages:
tzdata-europe-2018f-r0.noarch.rpm 236 kB/s | 25 kB 00:00
--------------------------------------------------------------------------------
Total 202 kB/s | 25 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : tzdata-europe-2018f-r0.noarch 1/1
Verifying : tzdata-europe-2018f-r0.noarch 1/1

Installed:
tzdata-europe.noarch 2018f-r0

Complete!
root@desk-mx6:~#
</pre>

and then configure it using <code>timedatectl</code>

<pre class="board-terminal">
root@desk-mx6:~# timedatectl set-timezone Europe/Rome
root@desk-mx6:~# timedatectl status
Local time: Tue 2022-02-22 13:16:08 CET
Universal time: Tue 2022-02-22 12:16:08 UTC
RTC time: Tue 2022-02-22 12:16:09
Time zone: Europe/Rome (CET, +0100)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
root@desk-mx6:~#
</pre>


By default, working with a distribution with systemd, you should have the <code>systemd-timesyncd</code> daemon by default, as seen before:

systemd-timesyncd.service active: yes
8,254
edits