zoukankan      html  css  js  c++  java
  • 0002_20190328_Centos修改系统时间

    一.   设置修改时间:

    1. 查看当前时区:
    [root@localhost bin]# date -R
    
    Thu, 28 Mar 2019 11:31:19 +0800

      2. 查看时间和日期:

    [root@localhost bin]# date
    
    2019年 03月 28日 星期四 11:32:38 CST

      3. 查看硬件时间:

    [root@localhost bin]# hwclock --show

      4. 设置当前日期:

    [root@localhost bin]# date -s 2019-3-28

      5. 设置硬件时间:

    [root@localhost bin]#  hwclock --set --date="2019-3-28 11:41:05"

      6.设置当前时间:

    [root@localhost bin]# date -s 11:34:28
    
    2019年 03月 28日 星期四 11:34:28 CST

      7.将当前时间写入BIOS, 防止重启失效

    [root@localhost bin]# hwclock –w

      8. 替换系统时区时间:

      设置中国时区使用重庆时间

    [root@localhost bin]# cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime 

    二.   时间同步:

    1. 系统和硬件时间相互同步:
    [root@localhost bin]#  hwclock –hctosys  #硬件时间写入到系统时间
    
    [root@localhost bin]#  hwclock –systohc  #软件时间写入到硬件时间

      2. 同步网络上的时间:

    a) 同步网络时间需要安装ntpdate时间同步服务软件;
    b) 检查本机是否安装ntpdate
    
    [root@localhost ~]# yum list installed | grep ntpdate     
    [root@localhost ~]# rpm -qa |grep ntpd*
    
    c) 使用yum安装ntpdate
    
    [root@localhost ~]# yum install -y ntpdate
    
    d) 选择服务器同步时间, 可用的服务器有下面几个:
    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
    [root@localhost ~]# ntpdate time.nist.gov  #同步时间服务器

    三.   添加定时任务, 同步时间:

    a)         每隔一小时同步网络时间

    [root@localhost ~]# #* */1 * * * root ntpdatetime.nuri.net;hwclock -w
  • 相关阅读:
    Seafile和Nextcloud相比较哪个好用
    opencv3.1+cmake+mingw5.3+QT5编译
    算法导论第三版--动态规划与贪心算法
    Linux 网卡特性配置ethtool详解
    算法导论第三版--红黑树
    算法导论第三版--二叉搜索树
    realloc在aarch64_be-gcc的奇怪表现
    算法导论第三版--桶排序
    算法导论第三版--计数,基数排序
    算法导论第三版--插入排序和归并排序
  • 原文地址:https://www.cnblogs.com/wxylog/p/10614038.html
Copyright © 2011-2022 走看看