修改服务器时间和时区

修改服务器时间和时区

1. 修改服务器时间
如果单纯修改服务器时间,通过ntpdate命令即可完成。

# yum install ntpdate -y
# ntpdate ntp1.aliyun.com

或者修改chronyd的配置文件

# vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
server ntp1.aliyun.com
....

重启chronyd服务

# systemctl restart chronyd

2. 修改服务器时区
首先确认服务器当前设置的时区

# timedatectl
      Local time: Thu 2020-11-26 10:15:24 CST
  Universal time: Thu 2020-11-26 02:15:24 UTC
        RTC time: Thu 2020-11-26 02:15:24
       Time zone: America/New_York (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

然后拷贝/usr/share/zoneinfo/主 时 区 / 主时区//次时区 到/etc/localtime

# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

版权声明:本文为weixin_47241409原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。