当前位置: 首页 >> Linux >> 【配置】系统时间使用utc时间要不要勾选 >> 正文

【配置】系统时间使用utc时间要不要勾选

6年前 (2018-05-23)     作者:Jiaozn     分类:Linux     阅读次数:4154     评论(0)    

UTC引发时区配置和Linux系统时间和bios时间问题

在安装Linux操作系统时,有一个选项是UTC,默认是勾上的。系统安装好后会把BIOS时间当成UTC标准时间,然后再根据时区调整系统时间。所以会发生明明时区设置正确,时间却不正确的情况。所以安装时,最好是取消那个勾。

 

如果已经装好,可以通过修改配置文件的方式修改。

redhat系统 修改/etc/adjtime第三行为LOCAL

[root@db-01 ~]# vim /etc/adjtime 

-0.098726 1524046105 0.000000
1524046105
LOCAL
~

The format of the adjtime file is, in ASCII:

       Line 1: 3 numbers, separated by blanks: 1) systematic drift rate in seconds per  day,  floating
       point decimal; 2) Resulting number of seconds since 1969 UTC of most recent adjustment or cali-
       bration, decimal integer; 3) zero (for compatibility with clock(8)) as a decimal integer.

       Line 2: 1 number: Resulting number of seconds since 1969 UTC of most recent calibration.   Zero
       if  there has been no calibration yet or it is known that any previous calibration is moot (for
       example, because the Hardware Clock has been found, since that calibration, not  to  contain  a
       valid time).  This is a decimal integer.

       Line  3:  "UTC"  or  "LOCAL".  Tells whether the Hardware Clock is set to Coordinated Universal
       Time or local time.  You can always override this value with options  on  the  hwclock  command
       line.

       You can use an adjtime file that was previously used with the clock(8) program with hwclock.

 

 修改时区的方法

修改配置文件/etc/sysconfig/clock

更新时区tzdata-update

 

ubuntu系统

hwclock的时区在/etc/default/rcS文件中设置,里面有一个参数UTC,默认值为True,表示使用UTC时 区,如果设置为no,那表示使用osclock的时区

-------------------

CentOS系统时间与UTC时间不一致怎么办

	在安装完Centos Linux操作系统之后,点击系统的时间发现与现在所使用的时间不一致,相差有8小时,而在安装系统的时候我们选择的时区是上海,但是CentOS Linux默认的bios时间是utc时间(UTC是协调世界时(Universal Time Coordinated)英文缩写,是由国际无线电咨询委员会规定和推荐,并由国际时间局(BIH)负责保持的以秒为基础的时间标度。UTC相当于本初子午线(即经度0度)上的平均太阳时,过去曾用格林威治平均时(GMT)来表示.北京时间比UTC时间早8小时,以1999年1月1日0000UTC为例,UTC时间是零点,北京时间为1999年1月1日早上8点整。),所以我们在时间上面相隔了8个小时。这个时候bios的时间和系统的时间当然是不一致,一个代表 utc 时间,一个代表cst(+8时区),即上海的时间。
让我们动手将操作系统的时间进行同步吧!
在CentOS Linux中终端命令中执行以下命令:
1、vi /etc/sysconfig/clock   #编辑时间配置文件
     ZONE="Asia/Shanghai"
     UTC=false                          #设置为false,硬件时钟不于utc时间一致
     ARC=false
2、ln -sf /usr/share/zoneinfo/Asia/Shanghai    /etc/localtime    #linux的时区设置为上海时区
3、ntpdate 192.43.244.18    #对准时间
如果没有安装ntp服务器,刚需要先执行以下命令:
yum install ntp #安装ntp服务器
4、/sbin/hwclock --systohc   #设置硬件时间和系统时间一致并校准
好了,我们的CentOS linux系统时间和计算机硬件时间终于都是cst时间了,并且都是上海时区,终于是正常啦。


除非注明,发表在“Jiaozn的博客”的文章『【配置】系统时间使用utc时间要不要勾选』版权归Jiaozn所有。 转载请注明出处为“本文转载于『Jiaozn的博客』原地址https://www.jiaozn.com/reed/336.html
0

评论

发表评论   

昵称*

E-mail*(建议输入,以便收到博主回复的提示邮件)

网站

分享:

支付宝

微信