Linux 7 修改时区不生效

本文详细介绍了在Linux系统中查看和修改时区的方法,包括使用`date`命令检查当前时区,通过软链接设置时区,使用`timedatectl`命令调整,以及手动配置环境变量和使用`tzselect`工具。在尝试多种方法后,最终成功将时区修改为亚洲上海。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看当前时区

 

1

2

3

4

[root@tidb01 ~]# date

Sat Jun 27 13:58:27 EDT 2020

[root@tidb01 ~]# date -R

Sat, 27 Jun 2020 13:58:36 -0400

修改时区

方法一:

 

1

2

3

[root@tidb01 ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

[root@tidb01 ~]# ls -l /etc/localtime

lrwxrwxrwx 1 root root 35 Jun 28 02:08 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai

方法二:

1

[root@tidb01 ~]# timedatectl set-timezone Asia/Shanghai

方法三:

 

1

2

3

4

[root@tidb01 ~]# cat /etc/profile

[root@tidb01 ~]# cat .bash_profile 

[root@tidb01 ~]# cat .bash_profile 

TZ='Asia/Shanghai'export TZ

方法四:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

[root@tidb01 ~]# 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.

......

查询时区并没有修改成功

 

1

2

[root@tidb01 ~]# date

Sat Jun 27 13:58:50 EDT 2020

尝试将其他东8区时区操作系统上的Shanghai文件拷贝过来

 

1

2

[root@tidb02 ~]# cp /usr/share/zoneinfo/Asia/Shanghai .

[root@tidb02 ~]# scp Shanghai 192.168.30.101:/root

时区修改成功

 

1

2

3

4

[root@tidb01 ~]# date

Sat Jun 27 14:23:04 CST 2020

[root@tidb01 ~]# date -R

Sat, 27 Jun 2020 14:23:13 +0800

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值