我现在日本,所以把时区设为亚洲东京,但是windowsXP和hiweed的时间总不一致,hiweed小一个小时。
使用图形方式的time-admin设过时间和时区,用文本方式的tzconfig试过设置时区,使用date和hwclock设置时间,都确认无误。也查看了/etc/timezone
esn@esn-laptop:~$ cat /etc/timezone
Asia/Tokyo
也查看了/etc/localtime
esn@esn-laptop:~$ ls -l /etc/localtime
/etc/localtime -> /usr/share/zoneinfo/Asia/Tokyo
也查看了/etc/default/rcS,取消了UTC设置,即bios时间为系统本地时间:
esn@esn-laptop:~$ cat /etc/default/rcS | grep UTC
UTC=no
后来使用tzselect(不是用来设置,而是根据本机时间查询任何时区的当前时间),最后输出的一段话终于让我明白是怎么回事了
You can make this change permanent for yourself by appending the line
TZ='Asia/Muscat'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
以上时区设置都是针对整个系统的,但是每个用户还可以设置各自的时区,即在home目录中的.profile文件内设置TZ变量。立刻查看此文件,果然有
esn@esn-laptop:~$ cat .profile | grep TZ立刻注解掉此行,注销,重新登录,再用time-admin设置时间就正常了。
export TZ='Asia/Shanghai'
这里反映出图形界面time-admin的一个问题,时区是系统时区,时间却是按照当前用户设置的TZ变量给出的时间。如果用户没有设置TZ变量或TZ变量与系统时区设置一致,没有问题,但如果用户设置的时区与系统不同,则time-admin只能令人迷惑不解。
总结一下时间设置的注意点:
- /etc/default/rcS中UTC设为no,使用CST时间,即bios时间。(可以解决Linux与Windows时间相差8小时的问题)
- /etc/timezone和/etc/localtime设置系统时区的文件
- ~/.profile中“export TZ=xxxxx”设置当前用户的时区
- date设置系统时间的命令,hwclock设置硬件时间(即bios时间)的命令
- tzconfig设置系统时区的命令 (修改2),tzselect换算不同时区的时间的命令
没有评论:
发表评论