Linux下配置自动更新时间

1,修正本地时区及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

2,自动同步时间

#添加下面一段
#表示每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 #查看时间

猜你喜欢

转载自blog.csdn.net/zha6476003/article/details/80617502