File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
# One-off synchronize time with htpdate.
4
4
# 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
5
8
6
9
set -ex
7
10
11
+ export DEBIAN_FRONTEND=noninteractive
12
+
8
13
apt-get update
9
14
apt-get install --assume-yes htpdate
10
15
16
+ # Ensure that the htpdate service is disabled in case the script times out before htpdate is removed
17
+ systemctl disable --now htpdate
18
+
11
19
echo " time before updating"
12
20
date
13
21
htpdate -s www.pool.ntp.org dk.pool.ntp.org www.wikipedia.org
14
22
echo " time after updating"
15
23
date
16
24
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
18
30
# (if NTP is blocked by the firewall)
19
- systemctl disable systemd-timesyncd
31
+ systemctl enable --now systemd-timesyncd
20
32
21
33
# Clean up and remove htpdate, as otherwise it leaves a service running which continually syncs time
22
34
# via htpdate
You can’t perform that action at this time.
0 commit comments