更改Linux系统时间及时区

更改Linux系统时间及时区


时区选择:

[root@master-c21 ~]# tzselect

  1. Asia
    #? 5

  2. China
    #? 9

  3. Beijing Time

  4. * Time
    #? 1

The following information has been given:

China
Beijing Time

Therefore TZ=‘Asia/Shanghai’ will be used.
Local time is now: Mon May 24 20:31:31 CST 2021.
Universal Time is now: Mon May 24 12:31:31 UTC 2021.
Is the above information OK?

  1. Yes
  2. 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

根据上面的提示,接下来开始操作:

[root@master-c21 ~]# date
Mon May 24 08:32:12 EDT 2021

这时候时间还是不对,
在profile文件中添加这一行

[root@master-c21 ~]# vim ~/.bash_profile
TZ=‘Asia/Shanghai’; export TZ

[root@master-c21 ~]# source ~/.bash_profile
[root@master-c21 ~]# date
Mon May 24 20:33:23 CST 2021

时间终于改过来了。

同步网络时间的命令:

ntpdate ntp1.aliyun.com

上一篇:[Linux] 查看并修改时区


下一篇:《利用python进行数据分析》第二版 第14章-数据分析示例 学习笔记1