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
     每隔十分钟同步一次。
  • 相关阅读:
    Electron应用打包、自动升级
    使用javascript处理nginx的请求
    使用Electron开发桌面应用
    VSCode、VBox搭建C/C++开发环境
    树莓派搭建Nexus2私服
    Tom猫小游戏功能实现
    如何配置webpack让浏览器自动补全前缀
    git 常用操作
    数组的一些常用操作
    ES6 的模块化
  • 原文地址:https://www.cnblogs.com/Spiro-K/p/6361770.html
Copyright © 2011-2022 走看看