技术分享 Linux下使用ntpdate进行时间同步

javier · 2019-01-06 16:37:10 · 热度: 20

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

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

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

Sun Jan  6 16:32:17 CST 2019

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

hwclock --systohc

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册