美文网首页
CentOS/Linux ntpdate自动同步服务器时间 20

CentOS/Linux ntpdate自动同步服务器时间 20

作者: 迷藏_ | 来源:发表于2019-03-01 08:10 被阅读8次

CentOS系统时间同步的步骤如下:

1、下载ntpdate
注:有些版本是没有自带ntpdate,因此需要下载
yum install -y ntpdate

2、调整时区为上海,也就是北京时间+8区
注:想改其他时区也可以去看看/usr/share/zoneinfo目录
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yes | cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

3、使用NTP来同步时间
ntpdate us.pool.ntp.org

4、定时同步时间(每隔10分钟同步时钟)
crontab -e
末尾追加
*/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP

这样我们就解决了时间问题。

相关文章

网友评论

      本文标题:CentOS/Linux ntpdate自动同步服务器时间 20

      本文链接:https://www.haomeiwen.com/subject/zirruqtx.html