centos7同步网络时间

  1. 使用date可以查看服务器时间

    [root@localhost sofeware]# date
    2019年 10月 29日 星期二 14:15:44 CST

  2. 安装ntpdate工具

    yum -y install ntp ntpdate

  3. 设置系统时区为上海

    timedatectl set-timezone Asia/Shanghai

    timedatectl status 查看是否成功

  4. 设置系统时间与网络时间同步

    ntpdate 0.asia.pool.ntp.org

    其他服务可用:
    ntpdate 1.asia.pool.ntp.org
    ntpdate 2.asia.pool.ntp.org
    ntpdate 3.asia.pool.ntp.org

  5. 将系统时间写入硬件时间 防止重启还原

    hwclock --systohc

  6. 加入定时任务每周同步一次

    * * * * 1 root ntpdate 0.asia.pool.ntp.org
    

    定时任务配置请参照:
    https://blog.csdn.net/liuxiaoming1109/article/details/102799093

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章