
日常维护中也经常会遇到服务器时间不一致的问题,今天给大家介绍一种linux系统自动更新时间的方法。
安装NTP/修正本地时区
[root@VM_0_13_centos ~]# yum -y install ntp
[root@VM_0_13_centos ~]# rm -rf /etc/localtime
[root@VM_0_13_centos ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@VM_0_13_centos ~]# /usr/sbin/ntpdate -u pool.ntp.org
设置自动同步时间
#表示每10分钟同步一次
[root@VM_0_13_centos ~]# crontab -e
*/10 * * * * /usr/sbin/ntpdate -u pool.ntp.org >/dev/null 2>&1
[root@VM_0_13_centos ~]# service crond restart #重启
[root@VM_0_13_centos ~]# date #查看时间
原创文章,如若转载,请注明出处:https://www.misuan.com/1330.html