Linux中的各种时间概念

计算机世界中的时间:Unix时间

Unix 时间:是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒。

时区

时区是怎么划分的?世界各时区的时间如何统一表达?GMT、UTC、UNIX有什么区别?
来自 https://blog.csdn.net/zgdwxp/article/details/102728563

Linux时区设置

1、timedatectl命令用于查看系统的本地时间,UTC时间,时区,时间同步状态等信息
2、时区的配置文件存放在/usr/share/zoneinfo/目录下
3、sudo timedatectl set-timezone Asia/Shanghai 设置系统时区
4、有些Linux发行版可能需要重新启动某些服务才能使时区更改生效。可以用systemd-timedated命令重新启动服务以确保更改生效
sudo systemctl restart systemd-timedated

来自 https://www.zhihu.com/question/566737932/answer/3380901843

Linux系统时间、RTC时间和时区的概念

Linux系统有两个时间,一个是系统时间(Wall time),另一个是RTC(Real time clock)时间。

RTC时间是RTC芯片维护的时间,一般有单独供电,即使掉电也能继续计时。
每次Linux系统启动后在启动过程中会检测和挂载RTC驱动,在挂载后会自动从RTC芯片中读取时间并设置到系统时间中去。此后如果没有显式的通过命令去控制RTC的读写操作,系统将不会再从RTC中去获取或者同步设置时间。​
在这里插入图片描述

hwclock指令用于获取和操作rtc时间,使用时需要sudo权限
xtark@xtark:~/C_Program/test$ sudo hwclock --debug
hwclock,来自 util-linux 2.31.1
System Time: 1712680429.888860
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
上次漂移调整完成于1969(年)后 1712679883 秒
上次校准完成于1969(年)后 1712679883 秒
硬件时钟为 UTC 时间
将假设硬件时钟保持为 UTC 时间。
正在等等时钟滴答…
…已获取时钟滴答
从硬件时钟读取的时间:2024/04/09 16:33:50
硬件时钟时间:2024/04/09 16:33:50 = 1969(年)后 1712680430 秒
Time since last adjustment is 547 seconds
计算出的硬件锁偏差为 0.000000 秒
2024-04-10 00:33:49.883824+0800

xtark@xtark:~/C_Program/test$ hwclock --help
用法:
hwclock [function] [option…]
Time clocks utility.

功能:
-r, --show display the RTC time
–get display drift corrected RTC time
–set set the RTC according to --date
-s, --hctosys set the system time from the RTC
-w, --systohc set the RTC from the system time
–systz send timescale configurations to the kernel
-a, --adjust adjust the RTC to account for systematic drift
–predict predict the drifted RTC time according to --date

选项:
-u, --utc the RTC timescale is UTC
-l, --localtime the RTC timescale is Local
-f, --rtc use an alternate file to /dev/rtc0
–directisa use the ISA bus instead of /dev/rtc0 access
–date

-h, --help display this help
-V, --version display version

  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值