[NOTE] ClockSynchronize

Ubuntu

  • Check your current time-zone: cat /etc/timezone
  • Check if your clock is synchronized with the internet: timedatectl
1
2
3
4
5
6
7
8
root@openstack1:~/kubernetes# timedatectl
Local time: Tue 2019-12-17 10:30:02 UTC
Universal time: Tue 2019-12-17 10:30:02 UTC
RTC time: Tue 2019-12-17 10:30:02
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no

If you haven’t sychronized with internet, the value of System clock synchronize must be no

Use sudo systemctl restart systemd-timesyncd.service to activate timesyncd

1
2
3
4
5
6
7
8
9
10
root@openstack1:~/kubernetes# systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendo
Active: active (running) since Mon 2019-12-16 09:24:02 UTC; 1 day 1h ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 27584 (systemd-timesyn)
Status: "Synchronized to time server 91.189.94.4:123 (ntp.ubuntu.com)."
Tasks: 2 (limit: 4915)
CGroup: /system.slice/systemd-timesyncd.service
└─27584 /lib/systemd/systemd-timesyncd
  • The final key to synchronize the clock

sudo timedatectl set-ntp true

  • Switch your time-zone

timedatectl list-timezones to check all the time-zones.

sudo timedatectl set-timezone Asia/Shanghai

CentOS

  • Using command line

    1
    2
    3
    4
    5
    6
    7
    8
    9
    # installation
    yum install chrony
    # enable chronyd
    systemctl start chronyd
    systemctl enable chronyd
    # set timezone to Shanghai
    timedatectl set-timezone Asia/Shanghai
    # launch it
    timedatectl set-ntp yes