2019-02-09 CentOS 檢查和更改時區設置

今天查看日誌的時候發現時間不對,原因是安裝的時候沒選正確的時區。我的正確時區在london,但是顯示出來是New_York,這哪能忍,趕緊動手去改:

[axing@syslog-http ~]$ date
Thu  7 Feb 04:05:35 EST 2019
#/etc/localtime – It is a symlink to the file localtime or to the correct timezone file in the system located in /usr/share/zoneinfo/ directory.
[root@syslog-http zoneinfo]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 38 Feb  5 18:53 /etc/localtime -> ../usr/share/zoneinfo/America/New_York
[axing@syslog-http ~]$ timedatectl
      Local time: Thu 2019-02-07 04:05:42 EST
  Universal time: Thu 2019-02-07 09:05:42 UTC
        RTC time: Thu 2019-02-07 09:05:42
       Time zone: America/New_York (EST, -0500)
     NTP enabled: no
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2018-11-04 01:59:59 EDT
                  Sun 2018-11-04 01:00:00 EST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2019-03-10 01:59:59 EST
                  Sun 2019-03-10 03:00:00 EDT

查找自己時區的代碼可以使用這個命令:timedatectl list-timezones | grep Europe / Asia

[root@syslog-http zoneinfo]# timedatectl list-timezones | grep Europe
Europe/Amsterdam
Europe/Andorra
Europe/Astrakhan
Europe/Athens
Europe/Belgrade
Europe/Berlin
Europe/Bratislava
Europe/Brussels
Europe/Bucharest
Europe/Budapest
Europe/Busingen
Europe/Chisinau
Europe/Copenhagen
Europe/Dublin
Europe/Gibraltar
Europe/Guernsey
Europe/Helsinki
Europe/Isle_of_Man
Europe/Istanbul
Europe/Jersey
Europe/Kaliningrad
Europe/Kiev
Europe/Kirov
Europe/Lisbon
Europe/Ljubljana
Europe/London
Europe/Luxembourg
Europe/Madrid
Europe/Malta
Europe/Mariehamn
Europe/Minsk
Europe/Monaco
Europe/Moscow
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Riga
Europe/Rome
Europe/Samara
Europe/San_Marino
Europe/Sarajevo
Europe/Saratov
Europe/Simferopol
Europe/Skopje
Europe/Sofia
Europe/Stockholm
Europe/Tallinn
Europe/Tirane
Europe/Ulyanovsk
Europe/Uzhgorod
Europe/Vaduz
Europe/Vatican
Europe/Vienna
Europe/Vilnius
Europe/Volgograd
Europe/Warsaw
Europe/Zagreb
Europe/Zaporozhye
Europe/Zurich
#或者tzselect 命令,但tzselect只是幫我們把選擇的時區顯示出來,並不會實際生效,只是告訴我們怎麼樣去設置環境,有興趣的話就看看
[root@syslog-http ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 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) none - I want to specify the time zone using the Posix TZ format.
#? 8
Please select a country.
 1) Albania       18) Guernsey          35) Poland
 2) Andorra       19) Hungary           36) Portugal
 3) Austria       20) Ireland           37) Romania
 4) Belarus       21) Isle of Man       38) Russia
 5) Belgium       22) Italy         39) San Marino
 6) Bosnia & Herzegovina  23) Jersey            40) Serbia
 7) Britain (UK)      24) Latvia            41) Slovakia
 8) Bulgaria          25) Liechtenstein     42) Slovenia
 9) Croatia       26) Lithuania         43) Spain
10) Czech Republic    27) Luxembourg        44) Sweden
11) Denmark       28) Macedonia         45) Switzerland
12) Estonia       29) Malta         46) Turkey
13) Finland       30) Moldova           47) Ukraine
14) France        31) Monaco            48) Vatican City
15) Germany       32) Montenegro        49) Åland Islands
16) Gibraltar         33) Netherlands
17) Greece        34) Norway
#? 7

The following information has been given:

    Britain (UK)

實際修改時區要用timedatectl 命令:

[root@syslog-centos axing]# timedatectl set-timezone Europe/London
[root@syslog-centos axing]# date
Thu  7 Feb 09:14:34 GMT 2019
[root@syslog-centos axing]# timedatectl set-local-rtc 1
#將硬件時鐘調整爲與本地時鐘一致, 0 爲設置爲 UTC 時間

搞定收工

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章