LINUX系统更改系统时区

https://cloud.tencent.com/developer/article/2165428

Linux-Redhat系统更改系统时区

[root@localhost ~]# date #查看本地时间
Thu May 19 23:41:32 EDT 2022
[root@localhost ~]# hwclock --show #查看硬件时间
Thu 19 May 2022 11:42:07 PM EDT  -0.332325 seconds

当前系统版本: Red Hat Enterprise Linux Server release 7.0 (Maipo)

查看目前的时区:

[root@localhost ~]# timedatectl
      Local time: Thu 2022-05-19 23:48:45 EDT        #本地时间
  Universal time: Fri 2022-05-20 03:48:45 UTC
        RTC time: Fri 2022-05-20 03:48:45
        Timezone: America/New_York (EDT, -0400)        #现在系统的时区
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2022-03-13 01:59:59 EST
                  Sun 2022-03-13 03:00:00 EDT
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2022-11-06 01:59:59 EDT
                  Sun 2022-11-06 01:00:00 EST

修改时区为上海:

[root@localhost ~]# timedatectl
      Local time: Fri 2022-05-20 11:49:17 CST    #修改后的本地时间
  Universal time: Fri 2022-05-20 03:49:17 UTC
        RTC time: Fri 2022-05-20 03:49:17
        Timezone: Asia/Shanghai (CST, +0800)    #修改后的时区
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
[root@localhost ~]# date #当前系统时间
Fri May 20 11:49:21 CST 2022
[root@localhost ~]# hwclock --show #当前系统硬件时间
Fri 20 May 2022 11:49:29 AM CST  -0.924897 seconds

 同步网络时间协议(NTP): 为了确保系统时间准确无误,建议启用NTP时间同步。

sudo timedatectl set-ntp true

1). 安装NTP: 使用你的包管理器安装NTP服务。在基于Debian的系统(如Ubuntu)上,你可以使用下面的命令:

apt-get update
sudo apt-get install ntp

2). 检查NTP服务状态: 通过以下命令检查NTP服务是否正在运行:

sudo systemctl status ntp
#或者改为ntpd
sudo systemctl status ntpd

 

posted @ 2024-03-25 17:12  忧伤恋上了快乐  阅读(28)  评论(0编辑  收藏  举报