Linux如何修改时区?

赞赏 2016-07-18

Linux 服务器修改时区的两种方式


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

通过 tzselect 修改时区


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

  1. $ tzselect
  2. Please identify a location so that time zone rules can be set correctly.
  3. Please select a continent or ocean.
  4. 1) Africa
  5. 2) Americas
  6. 3) Antarctica
  7. 4) Arctic Ocean
  8. 5) Asia
  9. 6) Atlantic Ocean
  10. 7) Australia
  11. 8) Europe
  12. 9) Indian Ocean
  13. 10) Pacific Ocean
  14. 11) none - I want to specify the time zone using the Posix TZ format.
  15. #? 5  输入5,选择亚洲
  16. Please select a country.
  17. 1) Afghanistan          18) Israel            35) Palestine
  18. 2) Armenia          19) Japan            36) Philippines
  19. 3) Azerbaijan          20) Jordan            37) Qatar
  20. 4) Bahrain          21) Kazakhstan        38) Russia
  21. 5) Bangladesh          22) Korea (North)        39) Saudi Arabia
  22. 6) Bhutan          23) Korea (South)        40) Singapore
  23. 7) Brunei          24) Kuwait            41) Sri Lanka
  24. 8) Cambodia          25) Kyrgyzstan        42) Syria
  25. 9) China          26) Laos            43) Taiwan
  26. 10) Cyprus          27) Lebanon            44) Tajikistan
  27. 11) East Timor          28) Macau            45) Thailand
  28. 12) Georgia          29) Malaysia            46) Turkmenistan
  29. 13) Hong Kong          30) Mongolia            47) United Arab Emirates
  30. 14) India          31) Myanmar (Burma)        48) Uzbekistan
  31. 15) Indonesia          32) Nepal            49) Vietnam
  32. 16) Iran          33) Oman            50) Yemen
  33. 17) Iraq          34) Pakistan
  34. #? 9  输入9,选择中国
  35. Please select one of the following time zone regions.
  36. 1) east China - Beijing, Guangdong, Shanghai, etc.
  37. 2) Heilongjiang (except Mohe), Jilin
  38. 3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
  39. 4) most of Tibet & Xinjiang
  40. 5) west Tibet & Xinjiang
  41. #? 1  输入1,选择北京时间
  42. The following information has been given:
  43.    China
  44.    east China - Beijing, Guangdong, Shanghai, etc.
  45. Therefore TZ='Asia/Shanghai' will be used.
  46. Local time is now:    Mon Nov  9 13:40:51 CST 2015.
  47. Universal Time is now:    Mon Nov  9 05:40:51 UTC 2015.
  48. Is the above information OK?
  49. 1) Yes
  50. 2) No
  51. #? 1  输入1确认
  52. You can make this change permanent for yourself by appending the line
  53.    TZ='Asia/Shanghai'; export TZ
  54. to the file '.profile' in your home directory; then log out and log in again.
  55. Here is that TZ value again, this time on standard output so that you
  56. can use the /usr/bin/tzselect command in shell scripts:
  57. 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


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

 

 

登陆后阅读全文
阅读 1336 赞赏 0 有用 0 没用 0 收藏 0 分享

   



0 条留言

linux分享的头像

linux分享

每个软件都有确定的用途

相关文章

阿里云·业务运营团队内部的前端构建和工程化工具 Dawn开源

阿里云云盾扫描服务器的的IP段有哪些?

阿里云云盾扫描服务器的的IP段有哪些?

安全组设置允许SSH登录到 Linux 实例

Linux 流控原理,实现,及实例

Linux 如何使用 kpartx 命令读取分区表信息

云服务器 ECS Linux /tmp 目录文件是如何做到定期清理的?

Linux Web 环境配置站点的方法

Linux 内核配置问题导致 NAT 环境访问异常

Linux Mac Window网络异常时如何抓包?

有料推荐

这世界欠我一个这样的老公!

高校学生模仿“世界名画”摆拍,可以说是戏精本精了

iPhone X 跌破发行价,苏宁200亿入股恒大 | 财经日日评

果然是高手!这次在日本,特朗普竹杠敲得不是一般狠

资深黄牛现身说法:iPhone X价格秒变不停,就像炒股一样

长一样的双胞胎也能识别?蚂蚁金服发布「眼纹识别」技术

苏联是怎么被阿富汗拖垮的?

美团或入局「分时租赁」共享汽车,王兴要大笔投入「泛出行」领域了? | 36氪独家

你或许被“一盘番茄炒蛋”刷屏了,但有人辛酸,有人质疑

iPhone X发售前夜,黄牛与苹果公司的不安

他的文章

我是如何执行 "rm -rf ~" 的

正态分布为什么常见?(财富的分布却不符合正态分布)

Linux下窗口管理器 xmonad 的使用教程

用披萨做比喻来解释 IaaS,PaaS,SaaS 的区别

如何制作CSR(证书私钥和证书请求文件)文件?

php RedisException with message read error on connection

Windows环境下ping丢包或不通时链路测试工具推荐

Linux下ping丢包或不通时链路测试工具推荐

链路测试结果分析说明及常见链路异常场景和测试报告

SSH 登录时出现如下错误:login: Module is unknown

手机扫一扫
分享文章