设置CentOS7的时间与网络同步

283 阅读1分钟

一、设置时区为上海

timedatectl set-timezone Asia/Shanghai

二、安装ntp服务

yum install -y ntp

三、修改ntp相关参数

vi /etc/sysconfig/ntpd

#修改文本
SYNC_HWCLOCK=yes
OPTIONS="-g -x"

下图是初始参数

image.png

将其修改为:

image.png

四、启动ntp服务

systemctl restart ntpd

五、设置ntp服务开机启动

systemctl enable ntpd

六、设置Linux系统时钟与远程NTP服务器同步

timedatectl set-ntp true

七、查看系统时间

timedatectl 

image.png