centos6 时区设置无效
滿天的星座
滿天的星座 2017-04-26 09:01:59
0
1
1087

一台测试服务器,之前设置为Asia/Shanghai,但是前两天突然时区失效了。
失效之前曾经升级过libc-2.12.so -> libc-2.14.so,不知道有没有关系。

# date
Fri Feb 10 07:01:22 Local time zone must be set--see zic manual page 2017
# date -R
Fri, 10 Feb 2017 07:14:10 +0000

用了tzselect重新选择,无效。

重置/etc/localtime,无效

rm -f /etc/localtime
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

/etc/sysconfig/clock设置也无效

ZONE="Asia/Shanghai"
TZ="Asia/Shanghai"
UTC=false
ARC=false

最后在.bash_profile里面设置TZ='America/Nassau'; export TZ,却只对当前用户有效,对其他用户还是无效的。

# sudo -u www-data date
Fri Feb 10 06:52:02 Local time zone must be set--see zic manual page 2017

系统版本如下:

LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:    CentOS
Description:    CentOS release 6.4 (Final)
Release:    6.4
Codename:    Final

google,百度都翻了个底,还是找不到解决办法,只能来这里求助了。

滿天的星座
滿天的星座

reply all(1)
PHPzhong

Okay, I solved it myself.

The reason is caused by the upgradelibc.so.6!

The description of the TZ environment variable in GNU points out that if TZ没有值,会默认选择时区,具体地址由libc.so.6这个库决定。在升级前,centos的默认时区文件为/etc/localtime。而我新编译的库时,设置了--prefix=/usr/local/glibc-2.14,导致默认路径为变成了/usr/local/glibc-2.14/etc/localtime, the default time zone will naturally not be found.

Solution:

ln -sf /etc/localtime /usr/local/glibc-2.14/etc/localtime

done!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template