zoukankan      html  css  js  c++  java
  • LINUX下的时间与时区的设置

    在RHEL下,如果只装英文版系统,设置好时区以后(上海时间,UTC)

    在命令行下用date命令查看,总是与实际的北京时间差8小时,其实硬件时间都是准确的。会带来视觉不便。

    今天下决心解决此问题,不过也没费时,有人写好了。

    http://www.opsers.org/linux-home/base/talk-about-rhel6-system-issues-an-eight-hour-time-difference.html

    方法很简单:

    复制正确时区文件

    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 

    date -R

    显示当前系统时间

    date -s "将上面显示的时间复制过来"

    hwclock -w --localtime 设置硬件时间

    hwclock -s --localtime #可将此句加入/etc/rc.local

    让硬件时间使用本地时间即可。

    [root@yufei ~]# hwclock --help
    hwclock - query and set the hardware clock (RTC)
    
    Usage: hwclock [function] [options...]
    这里需要大家特别注意:先是函数后是参数,只用其中一个是没有用的,这是解决问题的关键
    
    Functions:
      -r | --show         read hardware clock and print result #读取硬件(BIOS)时间,并显示出来
      -s | --hctosys      set the system time from the hardware clock #把目前系统时间调整为硬件时间
      -w | --systohc      set the hardware clock to the current system time #把硬件时间调整为目前系统的时间
           --systz        set the system time based on the current timezone #把系统时间设置为当时时区的时间
    
    Options:
      -u | --utc          the hardware clock is kept in UTC #设置硬件为的UTC时间
           --localtime    the hardware clock is kept in local time #设置硬件为本地时间

    想深入了解一下?:
    http://kerrigan.sinaapp.com/post-6.html
  • 相关阅读:
    关于在Websphere下程序找不到jar包内.properties文件的问题
    MysqL的root用户不允许远程连接
    ajax提交表单数据到controller
    js表单验证
    jq删除标签中的元素
    点击超链接触发js事件
    spring的特点
    mysql每个jar包的作用
    抽象工厂举例
    简单的省市联动
  • 原文地址:https://www.cnblogs.com/biangbiang/p/3561001.html
Copyright © 2011-2022 走看看