I have a cronjob running that checks for server updates, installs them one by one, and then checks if a reboot is needed. If a reboot is needed, the script will reboot
the server.
The hardware clock is used at boot time, Takes a minute, before the system clock is used.
Before the switch to the system clock, the logs shows that the server is an hour or so behind, when it the server switches from hardware to system clock, the logs jump and hour or so ahead, which triggers the cron daemon, it noticed that the time already has passed for the server update script, and executes it again.
Which triggers a reboot loop, because the script was only meant to be executed once a week.
Excecuting hwclock --systohc
syncs the system clock with the hardware clock, but it is not permanent. After a reboot, the time difference is off again.
My questions is
How do I permanently sync the system clock with the hardware clock?
output of timedatectl status
:
Local time: Tue 2018-08-28 12:05:37 CEST
Universal time: Tue 2018-08-28 10:05:37 UTC
RTC time: Tue 2018-08-28 10:05:37
Time zone: n/a (CEST, +0200)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: yes
DST active: yes
Last DST change: DST began at
Sun 2018-03-25 01:59:59 CET
Sun 2018-03-25 03:00:00 CEST
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2018-10-28 02:59:59 CEST
Sun 2018-10-28 02:00:00 CET
Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.
- CentOS Linux release 7.5.1804 (Core)
- This is a VPS server.
- Europe/Amsterdam
timedatectl status
.