在云服务器 ECS Linux 系统中,以 Centos6.5 为例,可以通过如下两种方式,修改系统时区:

可以使用命令 tzselect,修改时区。操作示例:

[root@localhost ~]# 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
Please select a country.
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
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & Xinjiang
5) west Tibet & Xinjiang
#? 1 The following information has been given: China
east China - Beijing, Guangdong, Shanghai, etc. Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Tue Jul 19 22:05:59 CST 2016.
Universal Time is now: Tue Jul 19 14:05:59 UTC 2016.
Is the above information OK?
1) Yes
2) No
#? yes
Please enter 1 for Yes, or 2 for No.
#? 1 You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; 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/Shanghai

通过修改配置文件修改时区


也可以直接通过修改配置文件来变更时区。

  1. vi /etc/sysconfig/clock
  2. ZONE=Asia/Shanghai(查/usr/share/zoneinfo下面的文件)
  3. rm /etc/localtime
  4. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@localhost zoneinfo]# ll /etc/localtime
-rw-r--r--. 1 root root 2819 Jun 29 2015 /etc/localtime
[root@localhost zoneinfo]# cat /etc/sysconfig/clock
ZONE="America/Los_Angeles"
UTC=true
ARC=false
[root@localhost ~]# cd /usr/share/zoneinfo
[root@localhost zoneinfo]# ll
总用量 560
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Africa
drwxr-xr-x. 6 root root 4096 Jun 29 2015 America
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Antarctica
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Arctic
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Asia
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Atlantic
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Australia
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Brazil
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Canada
-rw-r--r--. 1 root root 2102 Oct 30 2008 CET
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Chile
-rw-r--r--. 1 root root 2294 Oct 30 2008 CST6CDT
-rw-r--r--. 2 root root 2411 Oct 30 2008 Cuba
-rw-r--r--. 1 root root 1876 Oct 30 2008 EET
-rw-r--r--. 2 root root 9307 Oct 30 2008 Egypt
-rw-r--r--. 2 root root 3533 Oct 30 2008 Eire
-rw-r--r--. 1 root root 118 Oct 30 2008 EST
-rw-r--r--. 1 root root 2294 Oct 30 2008 EST5EDT
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Etc
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Europe
-rw-r--r--. 1 root root 255 Oct 30 2008 Factory
-rw-r--r--. 7 root root 3661 Oct 30 2008 GB
-rw-r--r--. 7 root root 3661 Oct 30 2008 GB-Eire
-rw-r--r--. 10 root root 118 Oct 30 2008 GMT
-rw-r--r--. 10 root root 118 Oct 30 2008 GMT0
-rw-r--r--. 10 root root 118 Oct 30 2008 GMT-0
-rw-r--r--. 10 root root 118 Oct 30 2008 GMT+0
-rw-r--r--. 10 root root 118 Oct 30 2008 Greenwich
-rw-r--r--. 2 root root 1135 Oct 30 2008 Hongkong
-rw-r--r--. 1 root root 119 Oct 30 2008 HST
-rw-r--r--. 2 root root 1141 Oct 30 2008 Iceland
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Indian
-rw-r--r--. 2 root root 1622 Oct 30 2008 Iran
-rw-r--r--. 1 root root 4082 Oct 30 2008 iso3166.tab
-rw-r--r--. 3 root root 2197 Oct 30 2008 Israel
-rw-r--r--. 2 root root 481 Oct 30 2008 Jamaica
-rw-r--r--. 2 root root 331 Oct 30 2008 Japan
-rw-r--r--. 2 root root 211 Oct 30 2008 Kwajalein
-rw-r--r--. 2 root root 599 Oct 30 2008 Libya
-rw-r--r--. 1 root root 2102 Oct 30 2008 MET
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Mexico
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Mideast
-rw-r--r--. 1 root root 118 Oct 30 2008 MST
-rw-r--r--. 1 root root 2294 Oct 30 2008 MST7MDT
-rw-r--r--. 4 root root 2427 Oct 30 2008 Navajo
-rw-r--r--. 2 root root 2434 Oct 30 2008 NZ
-rw-r--r--. 2 root root 2018 Oct 30 2008 NZ-CHAT
drwxr-xr-x. 2 root root 4096 Jun 29 2015 Pacific
-rw-r--r--. 2 root root 2679 Oct 30 2008 Poland
-rw-r--r--. 2 root root 3439 Oct 30 2008 Portugal
drwxr-xr-x. 19 root root 4096 Jun 29 2015 posix
-rw-r--r--. 3 root root 3519 Oct 30 2008 posixrules
-rw-r--r--. 2 root root 405 Oct 30 2008 PRC
-rw-r--r--. 1 root root 2294 Oct 30 2008 PST8PDT
drwxr-xr-x. 19 root root 4096 Jun 29 2015 right
-rw-r--r--. 2 root root 724 Oct 30 2008 ROC
-rw-r--r--. 2 root root 380 Oct 30 2008 ROK
-rw-r--r--. 2 root root 402 Oct 30 2008 Singapore
-rw-r--r--. 3 root root 2721 Oct 30 2008 Turkey
-rw-r--r--. 2 root root 118 Oct 30 2008 UCT
-rw-r--r--. 6 root root 118 Oct 30 2008 Universal
drwxr-xr-x. 2 root root 4096 Jun 29 2015 US
-rw-r--r--. 6 root root 118 Oct 30 2008 UTC
-rw-r--r--. 1 root root 1873 Oct 30 2008 WET
-rw-r--r--. 2 root root 2194 Oct 30 2008 W-SU
-rw-r--r--. 1 root root 18724 Oct 30 2008 zone.tab
-rw-r--r--. 6 root root 118 Oct 30 2008 Zulu

备注:修改完时区需要重启生效,查看时区可以使用命令 date -R

最新文章

  1. HTML5+javascript实现图片加载进度动画效果
  2. iOS开发笔记4:HTTP网络通信及网络编程
  3. 包装设计模式的实现以改进BufferedReader中的readLine方法为例
  4. 解决java写入xml报错org.w3c.dom.DOMException:DOM002 Illeg
  5. mysql 发生系统错误1067的解决方法
  6. 一次MySQL死锁问题解决
  7. [array] leetcode - 41. First Missing Positive - Hard
  8. MAC使用小技巧之用好mac电脑?的10个必知的小技巧!
  9. js窗体间传值
  10. Microsoft Azure News(7) Azure B系列虚拟机
  11. eclipse中启动项目报内存溢出问题通过修改配置解决
  12. JSP内置对象——Exception对象
  13. c++ STL中的next_permutation
  14. API网关之Kong网关简介
  15. JAVA-JSP内置对象之request范围
  16. VS2017 无法使用"XXX"附加到应用程序
  17. js map()处理数组和对象数据
  18. DataGridView使用技巧十:单元格表示值的自定义
  19. python的N个小功能之正则匹配
  20. Android 解决ScrollView嵌入ListView | GridView | ScrollView显示问题

热门文章

  1. C++ 容器一些细节
  2. Tilera 服务器上hadoop单机版测试
  3. 【boost】BOOST_LOCAL_FUNCTION体验
  4. cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
  5. Could not find a transformer to transform "SimpleDataType{type=org.mule.transport.NullPayload
  6. Java沙箱技术
  7. Excel合并单元格数据
  8. Flex 拾色器改变背景
  9. mysql 清除数据库数据
  10. chrome内核浏览器缓存资源找回方法