centos 7 查看修改时区
- 查看时区
timedatectl
查看结果
Local time: Sat 2021-04-24 14:29:18 CST
#系统当前时间 CST 中国
Universal time: Sat 2021-04-24 06:29:18 UTC
#标准时区(格林威治时区)
RTC time: Sat 2021-04-24 06:29:16
Time zone: Asia/Shanghai ( CST, +0800)
选择的时区 上海 中国 +8时区
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
- 列出所有的时区
timedatectl list-timezones
- 修改时区
timedatectl set-timezone Asia/Shanghai
#修改命令 修改为那个时区
- 修改时间 重启后失效
timedatectl set-time "YYYY-MM-DD HH:MM:SS"
- 是否NTP服务器同步
timedatectl set-ntp yes #yes或者no
ntpdate -u ntp.api.bz #同步网络时间
- 配置时间服务器
# yum -y install ntp
# vim /etc/ntp.conf
# 将下面这四行内容注释掉
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
在下边添加
server ntp.aliyun.com
重新启动该
service ntpd start
systemctl enable ntpd.service