Linux系统时间与硬件时间的概念和修改

一、时钟概念

在Linux系统当中(本为所讲的系统均为CentOS7)有两个时钟,它们分别是:硬件时钟与系统时钟

那什么是硬件时钟与系统时钟呢?

硬件时钟:它靠主板的电池驱动,也可以叫它RTC时钟或者CMOS时钟

系统时钟:它是Linux系统内核时间,在Linux系统运行某种应用程序的时候,读取的时间都是系统时间

二、时间修改

1)查看系统时间

[root@test ~]# date;uptime
2020年 02月 29日 星期六 20:16:46 CST
 20:16:46 up 25 min,  1 user,  load average: 0.06, 0.06, 0.05

2)修改系统时间

[root@test ~]# date -s "2020-2-29 20:17:53"
2020年 02月 29日 星期六 20:17:53 CST

3)查看硬件时间

[root@test ~]# hwclock --show
2020年02月29日 星期六 20时18分50秒  -0.229001 秒

4)修改硬件时间

[root@test ~]# hwclock --set --date "2020-2-29 20:21:19"

5)从当前硬件时钟设置系统时间

[root@test ~]# hwclock --hctosys

6)从当前系统时间设置硬件时钟

[root@test ~]# hwclock --systohc

7)查看时区

[root@test ~]# timedatectl status
      Local time: 六 2020-02-29 20:26:06 CST
  Universal time: 六 2020-02-29 12:26:06 UTC
        RTC time: 六 2020-02-29 12:26:06
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

8)修改时区

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

9)重启系统

[root@test ~]# init 6  

【只是为了打发时间】 

猜你喜欢

转载自www.cnblogs.com/Linux-mds/p/12385381.html
今日推荐