前言
最近在学习linux的时候用date这个命令,改时间改的CentOS和主机时间不匹配了,然后不知道怎么改回来,虽然听说重启一下就好了,但是想不重启弄好,弄了很久才弄好,我下面把方法分享给大家。
1先下载ntp(有ntp的前两步不需要)
yum install -y ntp
2启动服务
systemctl start ntpd
3同步时间
ntpdate cn.pool.ntp.org
4将 /etc/localtime 这个文件弄走
mv /etc/localtime /etc/localtime.bf
5做一个软连接
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime