Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | Email

第 5 章 区域设置

目录

5.1. 时区设置 CentOS 6
5.1.1. 查看当前时区 /etc/sysconfig/clock
5.1.2. tzselect - select a timezone
5.1.3. 时区设置 CentOS 7
5.1.4. 修改时区并立即生效
5.2. 日期、时间
5.2.1. rdate - get the time via the network
5.3. 语言

5.1. 时区设置 CentOS 6

timeconfig

system-config-date

5.1.1. 查看当前时区 /etc/sysconfig/clock

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

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

重新启动后生效

5.1.3. 时区设置 CentOS 7

列出时区

# timedatectl list-timezones
			

设置时区

# timedatectl set-timezone Asia/Hong_Kong
			

查看时区

# timedatectl
			

5.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
			
comments powered by Disqus