1、安装ntp和ntpdate工具

yum -y install ntp ntpdate

2、ln -sf /usr/share/zoneinfo/Asia/Shanghai    /etc/localtime    #linux的时区设置为上海时区

3、设置系统时间与网络时间同步

ntpdate ntp1.aliyun.com

这里主要就是通过时间服务器对系统时间进行同步,所以ntp.ntsc.ac.cn并不是固定的,可使用的公共ntp服务器很多,可根据所在区域选择合适自己的ntp服务器,具体查看  《linux 国内 NTP时间服务器地址》 linux 国内 NTP时间服务器地址_whatday的博客-CSDN博客_linux 时间服务器地址

4、为了防止系统重启后时间被还原,需要将系统时间写入硬件时间

[root@localhost ~]# hwclock --systohc

其他参考:

NTP时间服务器简介  NTP时间服务器简介_whatday的博客-CSDN博客

linux 查看修改 系统 时区时间 linux 查看修改 系统 时区时间_whatday的博客-CSDN博客_linux查看系统时区

Logo

更多推荐