preface

Recently, I encountered such a problem at work: The local time of one of our Intranet servers differs from the UTC time by more than one hour. Since the server is not connected to the Internet, the network time cannot be synchronized. However, a service deployed on the server verifies signatures through time stamps. Therefore, you can only calibrate the local time of the server offline.

Synchronizing Linux Time

Changing the Current Time Zone

Set the local timezone to Shanghai, timedatectl set-timezone Asia/Shanghai.

Modify the machine hardware time

Set hardware time to current time, hwclock –set –date=”03/16/2021 22:00:00″.

Synchronizing system time

Synchronize machine time to system time, hwclock –hctosys. Conversely, if you want to synchronize system time to machine time, hwclock –systohc.