Linux调整系统时区/时间的方法


linux调整系统时区/时间的方法

一、找到相应的时区文件

/usr/share/zoneinfo/Asia/Shanghai

用这个文件替换当前的/etc/localtime文件。

步骤: cp -i /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

选择覆盖

二、安装ntpd

1.安装
yum install ntp
systemctl start ntpd.service
systemctl enable ntpd.service

2.修改配置
修改为阿里云ntp服务器
vim /etc/ntp.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 3.centos.pool.ntp.org iburst
server ntp.aliyun.com iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
server ntp5.aliyun.com iburst

3.同步
# ntpdate ntp1.aliyun.com

01 01 * * * ntpdate ntp1.aliyun.com