zoukankan      html  css  js  c++  java
  • CentOS 6 修改时间和时区及设置修改及时间同步

    一、时区

    date -R; date ; hwclock --show ; ps -ef|grep ntpd

    显示时区

    date --help 获取帮助
    
    date -R
    
    date +%z

    上面两个命令都可

    date -R; date +%z  

    主要就是后面的+0800,东八区

    修改时区(拷贝文件到指定目录,然后重启生效)

    cp -rp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime 

    时区的信息存在/usr/share/zoneinfo/下面,本机的时区信息存在/etc/localtime

    二、时间

    概念:Linux时间有两个

    系统时间:也叫软件时间(sys), 1970年1月1日到当前时间的秒数

    BOIS时间:也叫硬件时间(hc)

    显示时间

    date;hwclock -r  
    
    2012年 10月 19日 星期五 23:39:44 CST  
    
    2012年10月19日 星期五 23时39分45秒  -0.317993 seconds  

    设置时间

    date -s 20121019  
    
    date -s 23:40:00 

    没有网络的情况下可以用这个

    2、ntpdate

    ntpdate time.windows.com && hwclock -w  

    连网更新时间,如果成功,将系统时间,写入BOIS

    # 系统时间同步到硬件时间

    hwclock -w 或 hwclock --systohc 【sys系统时间,tohc硬件时间】

    # 硬件时间同步到系统时间

    clock –hctosys 或 hwclock --hctosys【hc代表硬件时间,sys代表系统时间】

    可以做到crontab里

    3、启动ntpd服务,开启后就不能用了

    先用ntpdate更新一下,确保时间不至于差别太大

    rpm -qa | grep ntp #查询一下可安装了
    
    chkconfig --list | grep ntp #看下服务情况
    
    chkconifg ntpd on
    
    service ntpd start 或/etc/init.d/ntpd start

    必要的话,设置一下/etc/ntp.conf,再把服务reload一下

  • 相关阅读:
    hdu1087Super Jumping! Jumping! Jumping!(dp)
    划分树 hdu4417Super Mario
    poj2240Arbitrage(map+floyd)
    hdu4282A very hard mathematic problem
    hdu1421搬寝室(dp)
    【洛谷P3806】【模板】点分治1
    【CF914E】Palindromes in a Tree
    GDOI2020 游记
    【POJ2296】Map Labeler
    【洛谷P6623】树
  • 原文地址:https://www.cnblogs.com/mxci/p/13029735.html
Copyright © 2011-2022 走看看