linux时间同步

本文介绍了如何在Linux系统中查看和管理时间,包括查看系统时间、硬件时间、时区信息,以及如何调整硬件时钟、设置时区、同步网络时间,并通过ntpdate命令更新系统时间。此外,还展示了如何将时间写入硬件时钟,确保系统与硬件时间一致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

更新时间和时间同步

1.查看系统时间

[root@localhost ~]# date

2019年 07月 10日 星期三 11:22:44 CST

2.查看硬件时间

[root@localhost ~]# hwclock

2019年07月10日 星期三 11时24分11秒 -0.618165 秒

3.查看系统时间方面的各种状态

[root@localhost ~]# timedatectl

Local time: 三 2019-07-10 11:25:08 CST

Universal time: 三 2019-07-10 03:25:08 UTC

RTC time: 三 2019-07-10 03:25:08

Time zone: Asia/Shanghai (CST, +0800)

NTP enabled: yes

NTP synchronized: yes

RTC in local TZ: no

DST active: n/a

4.列出所有时区

[root@localhost ~]# timedatectl list-timezones

Africa/Abidjan

Africa/Accra

Africa/Addis_Ababa

Africa/Algiers

Africa/Asmara

Africa/Bamako

Africa/Bangui

Africa/Banjul

Africa/Bissau

Africa/Blantyre

Africa/Brazzaville

Africa/Bujumbura

Africa/Cairo

Africa/Casablanca

...........

5.将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间

[root@localhost ~]# timedatectl set-local-rtc 0

[root@localhost ~]# timedatectl

Local time: 三 2019-07-10 11:29:10 CST

Universal time: 三 2019-07-10 03:29:10 UTC

RTC time: 三 2019-07-10 03:29:10

Time zone: Asia/Shanghai (CST, +0800)

NTP enabled: yes

NTP synchronized: yes

RTC in local TZ: no

DST active: n/a

6.安装ntp工具

yum -y install utp ntpdate

7.设置系统时间与网络时间同步

[root@localhost ~]# ntpdate cn.pool.ntp.org

10 Jul 14:44:06 ntpdate[24742]: adjust time server 119.28.206.193 offset -0.020508 sec

[root@localhost ~]# date

2019年 07月 10日 星期三 14:44:11 CST

8.将时间写入硬件时间

[root@localhost ~]# hwclock --systohc

9.设置系统时区为上海

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

m0_46192678

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

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

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

打赏作者

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

抵扣说明:

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

余额充值