更改Linux系统时间及时区

更改Linux系统时间及时区


时区选择:

[root@master-c21 ~]# tzselect

  1. Asia
    #? 5

  2. China
    #? 9

  3. Beijing Time

  4. Xinjiang 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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一生要强的Zz

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值