@Linux系统时间设定及查阅

@linux系统时间设定及查看

#时间查看命令及修改
[root@string ~]# date
Fri Mar 5 09:50:27 CST 2021
[root@string ~]# date +%Y-%m-%d
2021-03-05

格式化时间

[root@string ~]# # 09:58:30
[root@string ~]# date +%H:%M:%S
10:01:44
[root@string ~]# date +%Y-%m-%d_%H:%M:%S
2021-03-05_10:02:05

设置时间

[root@string ~]# date -s "2029-03-05 10:02:44"
Mon Mar 5 10:02:44 CST 2029
[root@string ~]# date +%Y-%m-%d_%H:%M:%S
2029-03-05_10:03:03

同步互联网时间

[root@string ~]# yum install -y ntpdate
[root@string ~]# ntpdate ntp.aliyun.com

系统硬件时钟

[root@string ~]# hwclock -r
Fri 05 Mar 2021 10:10:40 AM CST -0.271305 seconds

系统软件时钟

[root@string ~]# date
Mon Mar 5 10:03:30 CST 2029

获取硬件时间


[root@string ~]# hwclock -r
Fri 05 Mar 2021 10:13:19 AM CST -0.473926 seconds

将硬件时间同步到系统时间

[root@string ~]# hwclock -r
Fri 05 Mar 2021 10:13:19 AM CST -0.473926 seconds
[root@string ~]# date
Mon Mar 5 10:06:20 CST 2029
[root@string ~]# hwclock -s
[root@string ~]# date
Fri Mar 5 10:14:19 CST 2021

查看时区状态

[root@string ~]# timedatectl status
Local time: Fri 2021-03-05 10:26:39 CST
Universal time: Fri 2021-03-05 02:26:39 UTC
RTC time: Fri 2021-03-05 02:26:33
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a

设置时区

[root@string ~]# timedatectl set-timezone Asia/Shanghai
posted @ 2021-04-16 09:08  ଲ一笑奈&何  阅读(36)  评论(0编辑  收藏  举报