Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | About

9.2. CentOS 區域設置

9.2.1. 時區設置 CentOS 6

timeconfig

system-config-date

9.2.1.1. 查看當前時區 /etc/sysconfig/clock

[root@ntp ~]# cat /etc/sysconfig/clock
ZONE="Asia/Harbin"
UTC=true
ARC=false
			

9.2.1.2. tzselect - select a timezone

# 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.
#?
			

重新啟動後生效

9.2.1.3. 時區設置 CentOS 7

列出時區

# timedatectl list-timezones
			

設置時區

# timedatectl set-timezone Asia/Hong_Kong
			

查看時區

# timedatectl
			

9.2.1.4. 修改時區並立即生效

可用時區 /usr/share/zoneinfo

[root@ntp ~]# ls /usr/share/zoneinfo
Africa      Asia       Canada   Cuba   EST      Factory  GMT0       Hongkong  Iran         Japan      Mexico   Navajo   Poland      PRC      ROK        Universal  W-SU
America     Atlantic   CET      EET    EST5EDT  GB       GMT-0      HST       iso3166.tab  Kwajalein  Mideast  NZ       Portugal    PST8PDT  Singapore  US         zone.tab
Antarctica  Australia  Chile    Egypt  Etc      GB-Eire  GMT+0      Iceland   Israel       Libya      MST      NZ-CHAT  posix       right    Turkey     UTC        Zulu
Arctic      Brazil     CST6CDT  Eire   Europe   GMT      Greenwich  Indian    Jamaica      MET        MST7MDT  Pacific  posixrules  ROC      UCT        WET
			

執行 hwclock 後會立即生效

# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# hwclock
			

演示如下,你可以看到時區從 EDT 變為 CST

# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# date
Fri Jul  4 05:57:25 EDT 2014

# hwclock
Fri 04 Jul 2014 06:12:14 PM CST  -0.219192 seconds

# date
Fri Jul  4 18:12:17 CST 2014
			

9.2.2. 日期、時間

# date -s "2008-7-19"
# date -s 18:10
		

9.2.2.1. rdate - get the time via the network

# rdate time-a.nist.gov 查看
# rdate -s time-a.nist.gov 設置
			

9.2.3. 語言

system-config-language

vim /etc/sysconfig/i18n
LANG="en_US.UTF-8"
		

查看語言

locale -a