centos7中设置时区、更改UTC时间为CST时间

矫情吗;* 2021-09-21 10:34 1221阅读 0赞

设置系统时区

  1. # 交换式设置命令
  2. tzselect
  3. # 依次选择设置的时区即可,下方为设置过程
  4. [root@1889ac6ed47a /etc]# tzselect
  5. Please identify a location so that time zone rules can be set correctly.
  6. Please select a continent or ocean.
  7. 1) Africa
  8. 2) Americas
  9. 3) Antarctica
  10. 4) Arctic Ocean
  11. 5) Asia
  12. 6) Atlantic Ocean
  13. 7) Australia
  14. 8) Europe
  15. 9) Indian Ocean
  16. 10) Pacific Ocean
  17. 11) none - I want to specify the time zone using the Posix TZ format.
  18. #? 5
  19. Please select a country.
  20. 1) Afghanistan 18) Israel 35) Palestine
  21. 2) Armenia 19) Japan 36) Philippines
  22. 3) Azerbaijan 20) Jordan 37) Qatar
  23. 4) Bahrain 21) Kazakhstan 38) Russia
  24. 5) Bangladesh 22) Korea (North) 39) Saudi Arabia
  25. 6) Bhutan 23) Korea (South) 40) Singapore
  26. 7) Brunei 24) Kuwait 41) Sri Lanka
  27. 8) Cambodia 25) Kyrgyzstan 42) Syria
  28. 9) China 26) Laos 43) Taiwan
  29. 10) Cyprus 27) Lebanon 44) Tajikistan
  30. 11) East Timor 28) Macau 45) Thailand
  31. 12) Georgia 29) Malaysia 46) Turkmenistan
  32. 13) Hong Kong 30) Mongolia 47) United Arab Emirates
  33. 14) India 31) Myanmar (Burma) 48) Uzbekistan
  34. 15) Indonesia 32) Nepal 49) Vietnam
  35. 16) Iran 33) Oman 50) Yemen
  36. 17) Iraq 34) Pakistan
  37. #? 9
  38. Please select one of the following time zone regions.
  39. 1) Beijing Time
  40. 2) Xinjiang Time
  41. #? 1
  42. The following information has been given:
  43. China
  44. Beijing Time
  45. Therefore TZ='Asia/Shanghai' will be used.
  46. Local time is now: Sat Aug 29 10:33:56 CST 2020.
  47. Universal Time is now: Sat Aug 29 02:33:56 UTC 2020.
  48. Is the above information OK?
  49. 1) Yes
  50. 2) No
  51. #? 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

更改UTC时间为CST时间

  1. # 备份之前的localtime文件
  2. mv localtime{ ,.bak}
  3. # 更改CST上海时间
  4. ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  5. # 测试
  6. [root@1889ac6ed47a /etc]# date
  7. Sat Aug 29 10:38:26 CST 2020

系统所有亚洲的时区时间都放在了/usr/share/zoneinfo/Asia下了,用户可自行查看,系统/etc/localtime是一个软链接文件,每当系统调用本地时间都会从这个文件里读取,访问软链接localtime相当于访问/usr/share/zoneinfo/Asia/Shanghai时区文件。


想了解作者更多,请移步个人网站,欢迎交流、留言~
极客技术空间:https://elltor.com/

发表评论

表情:
评论列表 (有 0 条评论,1221人围观)

还没有评论,来说两句吧...

相关阅读

    相关 cst时间(utccst时间)

    美国洛杉矶22点是中国几点? 美国洛杉矶用的是太平洋时区,冬令时与北京相差16小时,所以美国洛杉矶22点是中国第二天14点;夏令时比标准时间早一个小时,与北京相差15小时