zoukankan      html  css  js  c++  java
  • Linux下使用ntpdate进行时间同步

    转摘自
    Linux下使用ntpdate进行时间同步
    https://www.cnblogs.com/zhi-leaf/p/6281549.html
    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小时同步一次时间。
    # vi /etc/crontab
    [root@localhost ~]# vi /etc/crontab
    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    HOME=/
    #最后一行增加,每小时同步一次
    * */1 * * * ntpdate 0.asia.pool.ntp.org

    4、使用date命令查看当前时间
    [root@localhost ~]# date
    Thu Dec 13 16:39:46 CST 2018

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

  • 相关阅读:
    Poj2033
    CodeForces 540
    CodeForces 548
    LeetCode#2 Add Two Numbers
    CodeForces 544A
    POJ 2431Expedition
    HLG1116-选美大赛
    清华学堂 列车调度(Train)
    清华学堂 LightHouse
    清华学堂 Range
  • 原文地址:https://www.cnblogs.com/ritchy/p/10114891.html
Copyright © 2011-2022 走看看