今天拿到了一台亚洲区的azure云服务器,使用date查看时间的时候发现时间不对。使用date -R的时候显示的是:

Mon, 19 Jul 2021 07:56:51 +0000

发现时区不对,于是乎开始修改时区操作:

1、使用tzselect生成想要的时区配置

也就是最终生成:TZ='Asia/Shanghai'; export TZ ,具体一步步操作如下参照,可略过直接看第2

[aroot@APP2 Asia]$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".1) Africa2) Americas3) Antarctica4) Asia5) Atlantic Ocean6) Australia7) Europe8) Indian Ocean9) Pacific Ocean
10) coord - I want to use geographical coordinates.
11) TZ - I want to specify the time zone using the Posix TZ format.
#? 4
Please select a country whose clocks agree with yours.1) Afghanistan          18) Israel            35) Palestine2) Armenia       19) Japan         36) Philippines3) Azerbaijan          20) Jordan            37) Qatar4) Bahrain       21) Kazakhstan        38) Russia5) Bangladesh       22) Korea (North)     39) Saudi Arabia6) Bhutan         23) Korea (South)     40) Singapore7) Brunei        24) Kuwait            41) Sri Lanka8) Cambodia          25) Kyrgyzstan        42) Syria9) 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) Beijing Time
2) Xinjiang Time
#? 1The following information has been given:ChinaBeijing TimeTherefore TZ='Asia/Shanghai' will be used.
Selected time is now:   Mon Jul 19 16:18:43 CST 2021.
Universal Time is now:  Mon Jul 19 08:18:43 UTC 2021.
Is the above information OK?
1) Yes
2) No
#? 1You can make this change permanent for yourself by appending the lineTZ='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

2、配置:/etc/profile 环境变量文件

可以看出上述一顿猛如虎的操作无非就是干一件事情,生成一句话: TZ='Asia/Shanghai'; export TZ ,生成后需要将这句话复制粘贴到你的 /etc/profile最后一行,操作如下:

sudo vim /etc/profile

粘贴到profile中:

# Set Timezone
TZ='Asia/Shanghai'; export TZ

编辑完系统环境变量配置文件后使用source /etc/profile重新加载配置文件

3、删除localtime文件

sudo rm /etc/localtime

4、连接到上海标准时区文件

sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

再次查看时区,验证已经生效成东八区时区

[aroot@APP2 ~]$ date -R
Mon, 19 Jul 2021 16:46:50 +0800

另可能需要的参照:Linux服务器同步网络时间请参照:[Linux](CentOS 8.x.x)服务器同步网络时间

:本文原创由 bluetata 发布于: https://bluetata.blog.csdn.net/ 转载请务必注明出处。

[ Linux ] 查看并修改时区相关推荐

  1. Linux查看与修改时区、时间的命令

    1.查看.修改Linux时区与时间 一.linux时区的查看与修改 1,查看当前时区 date -R 2,修改设置时区 方法1: tzselect 方法2: 仅限于RedHat Linux 和 Cen ...

  2. Linux查看和修改时区

    对于部署在海外的Linux服务器来说,拿到的机器时区和本地并不一样,导致运行在上面的应用也面临时区问题.所以有必要修改系统本地时区. 0x00:查看时区 查看当前生效的时区,可以简单的通过date命令 ...

  3. Linux 查看及修改时区

    查看时间及时区 查看当前时间 date 查看时区 cat /etc/timezone 修改时区 1.修改或设置Linux服务器时区 tzselect RedHat Linux/CentOS timec ...

  4. mysql sql查询时区_MySQL查看和修改时区的方法

    今天发现有一个程序插入的时间不对,而该字段是配置的默认值 CURRENT_TIMESTAMP,初步判断是数据库的时区设置问题. 查看时区 登录数据库查看时区配置: mysql> show var ...

  5. linux 设置时间为昨天,Linux —— 时间(tzselect、timedatactl命令,查看和修改时区,修改时区为东八区)...

    一.设置linux修改时区 首先查看当前时区 #date -R 显示结果为: [root@localhost 20190528]# date -R Wed, 29 May 2019 19:56:23 ...

  6. Linux —— 时间(tzselect、timedatactl命令,查看和修改时区,修改时区为东八区)

    一.设置linux修改时区 首先查看当前时区 #date -R 显示结果为: [root@localhost 20190528]# date -R Wed, 29 May 2019 19:56:23 ...

  7. linux查看和修改当前系统时间

    一.查看和修改Linux的时区 1. 查看当前时区 命令 : "date -R" 2. 修改设置Linux服务器时区 方法 A 命令 : "tzselect" ...

  8. Linux 系统如何修改时区

    怎样修改linux时区 如果你的 Linux 系统时区配置不正确,必需要手动调整到正确的当地时区.NTP 对时间的同步处理只计算当地时间与 UTC 时间的偏移量,因此配置一个 NTP 对时间进行同步并 ...

  9. Mysql查看和修改时区

    查看命令 mysql> show variables like '%time_zone%'; +------------------+--------+ | Variable_name | Va ...

最新文章

  1. NGUI_Depth
  2. java sdf.parse_用DateFormat的parse方法验证字符串是否是日期的问题
  3. Android布局之weight属性解析
  4. 为什么java需要静态类_为什么Java主要方法是静态的?
  5. vue-cookies的使用
  6. loadrunner录制事件为0_测试工具LoadRunner常见问题汇总,解决方案整理
  7. ubuntu修改用户名、计算机名、主目录名
  8. pthread_cleanup_push()/pthread_cleanup_pop()
  9. N - Dragon Balls(并查集+深度的意义
  10. 接口并发如何模仿用户点击率和提交率_洞察| 五大法则揭秘!在抖音如何打造“爆款”?...
  11. Appium-关于appium的原生控件的 xpath 定位问题及常用方法
  12. Javascript标准参考教程学习记录
  13. 2.业务架构·应用架构·数据架构实战 --- TOGAF理论全景解读
  14. 徐州有初中计算机编程,徐州初中分布大全(学校+地址+联系方式)
  15. 基于javaweb的在线购书商城系统(java+jsp+mysql+servlert+ajax)
  16. 第六章 三维全景技术
  17. Pr:基本图形(文本)
  18. 跨越生态裂谷 华为云Stack如何为企业智能化转型架桥铺路?
  19. android gpu 视频编码,Android短视频SDK转码实践
  20. 金蝶cloud后台数据库表说明

热门文章

  1. Java千问:开发Java程序为什么要配置环境变量?
  2. 【python】pyi文件
  3. 常见波形的傅里叶级数展开式
  4. pcie总线协议入门基础知识
  5. 迎接Ubuntu Flatpak Remix,预装了Flatpak支持的Ubuntu
  6. 【Http请求工具类】
  7. http和https请求工具类
  8. 论文笔记 Semantics-Guided Neural Networks for Efficient Skeleton-Based Human Action Recognition - CVPR
  9. nginx 配置报404 问题排查
  10. 【Designing ML Systems】第 7 章 :模型部署和预测服务