Skip to content

Commit 4950523

Browse files
author
Marcus Funch
committed
Merge branch 'feature/53286_fix_htpdate_script' into 'master'
: Fix htpdate script not updating hardware clock See merge request os2borgerpc/os2borgerpc-scripts!140
2 parents 1120415 + 3b23b03 commit 4950523

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

common/system/set_time_htpdate.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@
22

33
# One-off synchronize time with htpdate.
44
# Used on instances where NTP ports or NTP synchronization in general are blocked.
5+
# If possible, we recommend opening up in the firewall for NTP instead.
6+
7+
# This script may cause jobmanager to time out due to changes in the time settings
58

69
set -ex
710

11+
export DEBIAN_FRONTEND=noninteractive
12+
813
apt-get update
914
apt-get install --assume-yes htpdate
1015

16+
# Ensure that the htpdate service is disabled in case the script times out before htpdate is removed
17+
systemctl disable --now htpdate
18+
1119
echo "time before updating"
1220
date
1321
htpdate -s www.pool.ntp.org dk.pool.ntp.org www.wikipedia.org
1422
echo "time after updating"
1523
date
1624

17-
# Disabling this service since it's under suspicion for interfering and syncing the time back to be incorrect
25+
# htpdate only updates the system clock so update the hardware clock from the system clock
26+
hwclock --systohc
27+
28+
# Enabling this service as previous versions of the script disabled it
29+
# because it was under suspicion for interfering and syncing the time back to be incorrect
1830
# (if NTP is blocked by the firewall)
19-
systemctl disable systemd-timesyncd
31+
systemctl enable --now systemd-timesyncd
2032

2133
# Clean up and remove htpdate, as otherwise it leaves a service running which continually syncs time
2234
# via htpdate

0 commit comments

Comments
 (0)