Skip to content

Commit 36ceb7e

Browse files
committed
feat: Use timesyncd with recovery clock file
Replaced ntpd with sytemd timesyncd. This allows to use a recovery clock file to have a more accurate system time during boot up. This greatly helps with log file timestamps. Otherwise they always start in 2019 and journal logs get all messed up until time synchronization is available. The recovery clock file is updated 2min after boot up, thereafter every 5 minutes and before shutdown. Whenever timesyncd receives a time update the file is updated as well internally by timesyncd. More information: https://wiki.archlinux.org/index.php/Systemd-timesyncd
1 parent 4dffcb5 commit 36ceb7e

8 files changed

+34
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../shutdown-clock-file.service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../update-clock-file.timer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Final clock file update before shutdown
3+
RequiresMountsFor=/
4+
5+
[Service]
6+
ExecStop=/etc/update_clock_file.sh
7+
Type=oneshot
8+
RemainAfterExit=yes
9+
10+
[Install]
11+
WantedBy=multi-user.target
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
[Unit]
3+
Description=Run clock file update script
4+
RefuseManualStart=no
5+
RefuseManualStop=no
6+
7+
[Service]
8+
Type=oneshot
9+
ExecStart=/etc/update_clock_file.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Unit]
2+
Description=Clock file update timer
3+
4+
[Timer]
5+
OnBootSec=120
6+
OnUnitActiveSec=300
7+
8+
[Install]
9+
WantedBy=multi-user.target

overlay/etc/update_clock_file.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /usr/bin/env sh
2+
touch /var/lib/systemd/timesync/clock

overlay/opt/yio/scripts/firstrun.sh

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ then
88
#--------------------
99
# Do some setup with services
1010
#--------------------
11-
systemctl disable systemd-timesyncd.service
1211
systemctl disable dhcpcd.service
1312
systemctl disable lighttpd.service
1413

rpi0/defconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ BR2_PACKAGE_IW=y
9494
BR2_PACKAGE_LIGHTTPD=y
9595
BR2_PACKAGE_LIGHTTPD_PCRE=y
9696
BR2_PACKAGE_NTP=y
97+
# BR2_PACKAGE_NTP_NTPD is not set
9798
BR2_PACKAGE_WPA_SUPPLICANT=y
9899
BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y
99100
BR2_PACKAGE_WPA_SUPPLICANT_WIFI_DISPLAY=y
@@ -105,7 +106,6 @@ BR2_PACKAGE_BASH=y
105106
# BR2_PACKAGE_SYSTEMD_HWDB is not set
106107
# BR2_PACKAGE_SYSTEMD_MYHOSTNAME is not set
107108
BR2_PACKAGE_SYSTEMD_RFKILL=y
108-
# BR2_PACKAGE_SYSTEMD_TIMESYNCD is not set
109109
BR2_PACKAGE_UTIL_LINUX_KILL=y
110110
BR2_PACKAGE_UTIL_LINUX_RFKILL=y
111111
BR2_PACKAGE_NANO=y

0 commit comments

Comments
 (0)