在CentOs上部署nginx時會遇到時區的問題,有時候改完系統重啓完還是會出錯,so,需要配置成下面的NTP同步狀態
[root@localhost ~]# timedatectl
Local time: Tue 2019-12-24 16:37:04 CST
Universal time: Tue 2019-12-24 08:37:04 UTC
RTC time: Tue 2019-12-24 16:37:04
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: yes
DST active: n/a
使用 date 命令,查看系統時間和當前時間是否一致,如果不一致,就需要使用ntp同步標準時間,ntp:網絡時間協議(network time protol)
安裝:yum install ntp
同步:ntpdate pool.ntp.org
查看下面三個是否都是yes,如果缺了就使用下面的命令:
# NTP enabled: yes
timedatectl set-ntp on
# NTP synchronized: yes
# 將當前時間和日期寫入BIOS,避免重啓後失效
hwclock -w
# RTC in local TZ: yes
timedatectl set-local-rtc 1