今天碰到了一个很奇怪的问题,好好的,我在一个CentOS下面居然改不了时区。
先是直接按老办法修改/etc/localtime,结果没用,接着,又修改/etc/sysconfig/clock文件,还是没用。
接着用system-config-time命令进行修改,居然都没有用。。。
怀疑缓存问题(我居然会想到这个,蠢透了),重启机器,还是没用。。。
后来想起来一个专门调节时区的命令:tzselect,试了试,依然没有用。
不过,突然发现有这么一行信息:
You can make this change permanent for yourself by appending the line
TZ='Europe/Mariehamn'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
TZ='Europe/Mariehamn'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
在想,会不会是TZ这个变量在做怪,重新登陆了系统,发现这台机器上的TZ变量居然已经设置好了,对比正确的机器,这个值应该是空的。于是,清空了这个值,前面的修改就可以生效了。
最后检查了一下原因,不知道什么时候有人添加了这个文件:
/etc/profile.d/tz.sh
将这个文件删除,一切都OK!