有時當我們裝Ubuntu系統時,沒有設定好時區,導致Log的時間記錄不正確,可以事後進行時區及時間的校正,做法如下

# date
Mon Apr 20 15:37:06 AST 2015

# tzselect

Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) coord - I want to use geographical coordinates.
12) TZ - I want to specify the time zone using the Posix TZ format.
#? 5 這裡按5選Asia

Please select a country whose clocks agree with yours.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 43 這裡按43選Taiwan

The following information has been given:

Taiwan

Therefore TZ='Asia/Taipei' will be used.
Local time is now: Mon Apr 20 20:39:28 CST 2015.
Universal Time is now: Mon Apr 20 12:39:28 UTC 2015.
Is the above information OK?
1) Yes
2) No
#? 1 這裡按1確認剛剛的選擇

You can make this change permanent for yourself by appending the line
TZ='Asia/Taipei'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Taipei

# cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime

# ntpdate time.stdtime.gov.tw
20 Apr 20:40:21 ntpdate[9271]: adjust time server 118.163.81.61 offset -0.016625 sec

# date
Mon Apr 20 20:43:51 CST 2015

好了,這樣我們就把時間設定回+8 Taipei了.

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 痞客興 的頭像
    痞客興

    痞客興的部落格

    痞客興 發表在 痞客邦 留言(0) 人氣()