如何检查/ etc / localtime的内容?


23

我可以使用什么命令来检查时区文件的内容,例如/etc/localtime或下的文件/usr/share/zoneinfo/*


2
apropos -s 1 -a time zone
吉尔(Gilles)'所以

Answers:


34

最合适的命令似乎是zdump

$ zdump /etc/localtime 
/etc/localtime  Wed Aug  7 23:52:25 2013 EDT

$ zdump /usr/share/zoneinfo/* | tail -10
/usr/share/zoneinfo/Singapore    Thu Aug  8 11:52:48 2013 SGT
/usr/share/zoneinfo/Turkey       Thu Aug  8 06:52:48 2013 EEST
/usr/share/zoneinfo/UCT          Thu Aug  8 03:52:48 2013 UCT
/usr/share/zoneinfo/Universal    Thu Aug  8 03:52:48 2013 UTC
/usr/share/zoneinfo/US           Thu Aug  8 03:52:48 2013
/usr/share/zoneinfo/UTC          Thu Aug  8 03:52:48 2013 UTC
/usr/share/zoneinfo/WET          Thu Aug  8 04:52:48 2013 WEST
/usr/share/zoneinfo/W-SU         Thu Aug  8 07:52:48 2013 MSK
/usr/share/zoneinfo/zone.tab     Thu Aug  8 03:52:48 2013
/usr/share/zoneinfo/Zulu         Thu Aug  8 03:52:48 2013 UTC

您还可以使用以下file命令查询这些文件:

$ file /etc/localtime 
/etc/localtime: timezone data, version 2, 4 gmt time flags, 4 std time flags, no leap seconds, 235 transition times, 4 abbreviation chars

$ file /usr/share/zoneinfo/Singapore
/usr/share/zoneinfo/Singapore: timezone data, version 2, 8 gmt time flags, 8 std time flags, no leap seconds, 8 transition times, 8 abbreviation chars


0

脚步:

  1. 首先检查docker容器的本地时间:

    [root@locdb oracle]# zdump /etc/localtime
    /etc/localtime  Tue May 22 13:59:40 2018 UTC
    
  2. 检查时区,如下所示:

    [root@locdb oracle]# zdump /usr/share/zoneinfo/* | tail -10
    /usr/share/zoneinfo/UTC          Tue May 22 14:01:21 2018 UTC
    /usr/share/zoneinfo/Universal    Tue May 22 14:01:21 2018 UTC
    /usr/share/zoneinfo/W-SU         Tue May 22 17:01:21 2018 MSK
    /usr/share/zoneinfo/WET          Tue May 22 15:01:21 2018 WEST
    /usr/share/zoneinfo/Zulu         Tue May 22 14:01:21 2018 UTC
    /usr/share/zoneinfo/iso3166.tab  Tue May 22 14:01:21 2018
    /usr/share/zoneinfo/posix        Tue May 22 14:01:21 2018
    /usr/share/zoneinfo/posixrules   Tue May 22 10:01:21 2018 EDT
    /usr/share/zoneinfo/right        Tue May 22 14:01:21 2018
    /usr/share/zoneinfo/zone.tab     Tue May 22 14:01:21 2018
    
  3. 复制您需要的一个,例如:

    cp  /usr/share/zoneinfo/UTC /etc/localtime
    

在步骤2中更正命令:zdump / usr / share / zoneinfo / * | 尾巴-10
Shantonav Sen

我认为docker在此提及是对一般解决方案的干扰。
杰夫·谢勒

我也还看不出这与slm的答案
杰夫·谢勒

您是正确的@Jeff,我正在docker容器内尝试此解决方案,而又不影响hos,因此可能会混淆。
Shantonav Sen

-5

实际上,任何事情都可以通过字符串进行检查:

# strings /etc/localtime

4
是的,这实际上没有用。试试吧。它会带来很多垃圾,您无法真正分辨出语言环境的内容。
slm

还建议使用六角编辑器。
jgmjgm
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.