美文网首页
Linux 使用ntpdate进行时间同步

Linux 使用ntpdate进行时间同步

作者: 吴国友 | 来源:发表于2019-03-13 21:55 被阅读0次

1、安装ntpdate,执行以下命令

# yum install ntpdate -y

2、手工同步网络时间,执行以下命令,将从time.nist.gov同步时间

# ntpdate 0.asia.pool.ntp.org

若上面的时间服务器不可用,也可以选择以下服务器同步时间

time.nist.gov

time.nuri.net

0.asia.pool.ntp.org

1.asia.pool.ntp.org

2.asia.pool.ntp.org

3.asia.pool.ntp.org

  1. ntp1.aliyun.com

3、使用crontab计划任务定时更新网络时间,修改crontab文件,在末尾增加* */1 * * * ntpdate 0.asia.pool.ntp.org,每隔1小时同步一次时间。

# vi /etc/crontab

4、使用date命令查看当前时间

5、系统时间同步到硬件,防止系统重启后时间呗还原

# hwclock --systohc

6、把时间修改成上海的时间

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

相关文章

网友评论

      本文标题:Linux 使用ntpdate进行时间同步

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