计算机世界中的时间: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