zoukankan      html  css  js  c++  java
  • Linux:时间同步

    时间同步

    • 硬件时间的设置

                     hwclock clock   clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。

     查看硬件时间

    hwclock
    
    hwclock --show
    
    hwclock -r

     

    • 系统时间和硬件时间的同步

    同步系统时间和硬件时间,可以使用hwclock命令。

    以系统时间为基准,修改硬件时间

     

    hwclock --systohc<== sys(系统时间)to(写到)hc(Hard Clock)
     hwclock -w

    以硬件时间为基准,修改系统时间

    hwclock --hctosys
    hwclock -s 
    • 用ntpdate从时间服务器更新时间

    如果你的linux系统根本没有ntpdate这个命令

    yum install ntp 

    安装完了之后,你不要做什么配置,也不需要,直接测试一下

    ntpdate time.nist.gov  
    22 Oct 21:11:43 ntpdate[5014]: adjust time server 207.200.81.113 offset -0.018788 sec  

    如果出去上面的内容说明,同步成功了。然后在/etc/crontab里面加上以下内容。

     

      # Example of job definition:
      # .---------------- minute (0 - 59)
      # |  .------------- hour (0 - 23)
      # |  |  .---------- day of month (1 - 31)
      # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
      # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
      # |  |  |  |  |
      # *  *  *  *  * user-name command to be executed
       */5 * * * * ntpdate time.nist.gov   #域名或IP
     每隔十分钟同步一次。
  • 相关阅读:
    ps | grep排除grep这个进程
    树莓派3B安装LEDE
    从路由器镜像中提取uImage头信息
    提取路由器固件中的squashfs
    javascript监听按键
    linux 英汉词典程序shell+postgresql版
    树莓派(centos7)安装mysql
    在线视频下载利器——youtube-dl
    使用curl自动签到百度贴吧
    极路由hc5661安装tcpdump
  • 原文地址:https://www.cnblogs.com/Spiro-K/p/6361770.html
Copyright © 2011-2022 走看看