今天查看日志的时候发现时间不对,原因是安装的时候没选正确的时区。我的正确时区在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 时间
搞定收工