linux时间时区设置

  用linux的时候大家可能会遇到时间不对,时区不对的情况。比如使用网上廉价的国外的linux的vps,时区是国外的。那么如何在不劳烦管理员的情况下自己动手呢?首先要了解硬件时钟与系统时钟,计算机上的BIOS时间,这还得google一番,详情可参见http://kerrigan.sinaapp.com/post-6.html。当然了对于咱们来说会几个命令就行了:
hwclock -s --localtime

让硬件时间使用本地时间即可。
[root@remote ~]# 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 #设置硬件为本地时

posted @ 2014-02-22 18:39  康行天下  阅读(396)  评论(0编辑  收藏  举报