1. 查询系统时间和bios时间

- 查看系统时间
```powershell
[root@DBCENTER etc]# date
2021年 03月 05日 星期五 02:34:15 CST
```
- 查看bios时间
```powershell
[root@DBCENTER etc]# hwclock --show
2021年03月05日 星期五 02时35分21秒  -1.026306 秒
```

2. 通过date命令查询时区

[root@FJ050 ~]# date +"%Z %z"
CST +0800
或者
[root@FJ050 ~]# date -R
Thu, 04 Mar 2021 23:35:06 +0800

在这里插入图片描述

3. 修改时区

[root@FJ050 ~]# timedatectl set-timezone Asia/Shanghai
[root@FJ050 ~]# date -R
Thu, 04 Mar 2021 23:37:53 +0800

4. 安装NTP

[root@FJ050 ~]# sudo yum -y install ntp

5. 使用 ntpdate 校准时间

[root@FJ050 ~]# ntpdate pool.ntp.org
[root@FJ050 ~]# date
2021年 03月 04日 星期四 15:41:30 CST

在这里插入图片描述

中国-cn.pool.ntp.org
最好使用pool.ntp.org查找NTP服务器
服务器0.cn.pool.ntp.org
服务器1.cn.pool.ntp.org
服务器2.cn.pool.ntp.org
服务器3.cn.pool.ntp.org

6. 若想持续校准时间启动ntpd daemon

[root@FJ050 ~]# systemctl start ntpd
-- 查看ntpd daemon是否启动
[root@FJ050 ~]# systemctl status ntpd

在这里插入图片描述

7. 将Linux系统同步给BIOS时间

因为每次开机的时候系统会重新读取BIOS时间,所以当我们进行完DATE时间的校准后,还需要更新BIOS的时间

date -R 显示系统时间

-- 显示bios时间
hwclock --show 
或
hwclock -r

--  将系统时间写入bios(根据需要执行)
hwclock --systohc
或 
hwclock -w 

-- 将bios时间写入系统(根据需要执行)
hwclock --hctosys 

在这里插入图片描述

8. NPT协议介绍

网络时间协议,英文名称:Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。NTP的目的是在无序的Internet环境中提供精确和健壮的时间服务。

9. GMT、UTC、DST、CST时区区别

GMT:Greenwich Mean Time
格林威治标准时间;
英国伦敦格林威治定为0°经线开始的地方,地球每15°经度 被分为一个时区,共分为24个时区,相邻时区相差一小时;例: 中国北京位于东八区,GMT时间比北京时间慢8小时。

UTC: Coordinated Universal Time
世界协调时间;
经严谨计算得到的时间,精确到秒,误差在0.9s以内, 是比GMT更为精确的世界时间

DST: Daylight Saving Time
夏季节约时间,即夏令时;
是为了利用夏天充足的光照而将时间调早一个小时,北美、欧洲的许多国家实行夏令时;

CST:
CST同时可以代表如下 4 个不同的时区:
Central Standard Time (USA) UT-6:00 美国标准时间
Central Standard Time (Australia) UT+9:30 澳大利亚标准时间
China Standard Time UT+8:00 中国标准时间
Cuba Standard Time UT-4:00 古巴标准时间

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐