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

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

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

答案1

最合适的命令似乎是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

答案2

### For OpenWrt only ### Fixes /etc/TZ and /etc/localtime

curl -so - https://who.is/whois-ip/ip-address/`curl -s ifconfig.me`|\
    egrep 'Country:|City:'

IAMIN=Europe/Amsterdam
tail -1 /usr/share/zoneinfo/$IAMIN | tee /tmp/TZ
ln -s /usr/share/zoneinfo/$IAMIN /tmp/localtime

答案3

尝试 tzdump。我在这里找到了它:http://www.cise.ufl.edu/~seeger/dist/tzdump.c 它是一个 C 程序,因此需要编译。

相关内容