作家
登录

Linux服务器时间同步那些事

作者: 来源: 2017-11-20 10:22:47 阅读 我要评论

  • /etc/init.d/ntpd start#启动ntp同步 
  • 主动脚本如下:

    1. #!/bin/bash 
    2.  
    3. #备份源文件 
    4.  
    5. mv /etc/localtime /etc/localtimebak 
    6.  
    7. #修改时区为东八区 
    8.  
    9. ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
    10.  
    11. #安装ntp办事 
    12.  
    13. yum -y install ntpdate ntp 
    14.  
    15. #修改/etc/ntp.conf  
    16.  
    17. cat << EOF  >> /etc/ntp.conf  
    18.  
    19. server cn.pool.ntp.org 
    20.  
    21. server time-a.nist.gov 
    22.  
    23. server time.windows.com 
    24.  
    25. server time.nist.gov 
    26.  
    27. EOF 
    28.  
    29. #调试查看时光差别 
    30.  
    31. ntpdate -d cn.pool.ntp.org 
    32.  
    33. #同步时光 
    34.  
    35. ntpdate cn.pool.ntp.org && echo "SYNC_HWCLOCK=yes" >>/etc/sysconfig/ntpd || echo "Setting Filed!" 
    36.  
    37. #自启动 
    38.  
    39. chkconfig --levels 235 ntpd on 
    40.  
    41. /etc/init.d/ntpd start 
    42.  
    43. echo `date`   

    【编辑推荐】

    1. Linux体系启动故障若何修复?这几个案例帮你解决问题~
    2. 面试Linux运维必定会问到Shell脚本的┞封24个问题
    3. Linux内核4.14宣布:快来看看Linus的总结和超多新特点
    4. Linux Lite第一个支撑Linux 4.14及若何安装
    5. Linux平台总线驱动设备模型
    【义务编辑:庞桂玉 TEL:(010)68476606】

      推荐阅读

      克服容器采用的4个常见误区

    Tech Neo技巧沙龙 | 11月25号,九州云/ZStack与您一路商量云时代收集界线治理实践 容器是当今企业数字化转型的>>>详细阅读


    本文标题:Linux服务器时间同步那些事

    地址:http://www.17bianji.com/lsqh/39001.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)