date和hwclock

date和hwclockGMT GreenwichMea 即格林尼治标准时间 GMT 以地球自转为基础 但由于地球自转不均匀 导致 GMT 不精确 UTC UniversalTim 即协调世界时 UTC 是以原子时秒长为基础 在时刻上尽量接近于 GMT 的一种时间计量系统 RTC Real TimeClock 即实时时钟 在计算机领域作为硬件时钟的简称 硬件时间 保存在主板 BIOS 中 信息比较少没时区 夏令时的概念 系统时间 系统开机时读取硬件时间作为系统的时间 系统关机时再将系

注意:

1.date命令操作系统时间,hwclock操作硬件时钟,所以date 修改时间后,最好用hwclock 同步一下,以免系统非正常关机造成时间不同步。

2.hwclock 查看的时间并不一定就是RTC的时间,使用hwclock –localtime 查看才是寄存器中的值。

3.系统关闭时会同步系统时间到硬件时钟,系统启动时会从硬件时钟读取时间更新到系统,当主机运行很久都没有重启时就有可能发生系统时间与硬件时间不一样的情况。这2个步骤都要根据 /etc/sysconfig/clock 文件中UTC的参数来设置时区转换。

@ hwclock命令
1、查看硬件时间  hwclock

2、将系统时间同步到硬件时间  hwclock -w

3、将硬件时间同步到系统时间  hwclock -s

北京时间,17:16 # uptime 18:23:13 up 147 days, 5:04, 1 user, load average: 0.01, 0.04, 0.00 # # hwclock Wed 14 Apr 2021 06:16:09 PM JST -0. seconds # hwclock -u Wed 14 Apr 2021 06:16:12 PM JST -0. seconds # hwclock --localtime Wed 14 Apr 2021 09:16:16 AM JST -0. seconds # cat /etc/sysconfig/clock ZONE="Asia/Tokyo"

@ 修改时区

tzselect

[root@xxx bin]# tzselect Please identify a location so that time zone rules can be set correctly. Please select a continent or ocean.  1) Africa  2) Americas  3) Antarctica  4) Arctic Ocean  5) Asia  6) Atlantic Ocean  7) Australia  8) Europe  9) Indian Ocean 10) Pacific Ocean 11) none - I want to specify the time zone using the Posix TZ format. #? 6 Please select a country. 1) Bermuda 2) Cape Verde 3) Falkland Islands 4) Faroe Islands 5) Iceland 6) Portugal 7) South Georgia & the South Sandwich Islands 8) Spain 9) St Helena #? 5 The following information has been given:         Iceland Therefore TZ='Atlantic/Reykjavik' will be used. Local time is now:      Fri Apr  9 10:10:53 GMT 2021. Universal Time is now:  Fri Apr  9 10:10:53 UTC 2021. Is the above information OK? 1) Yes 2) No #? 1 You can make this change permanent for yourself by appending the line         TZ='Atlantic/Reykjavik'; export TZ to the file '.profile' in your home directory; then log out and log in again. Here is that TZ value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts: Atlantic/Reykjavik

注意:按照提示操作(如下),时区修改只会对本用户环境生效

参考资料:

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233342.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号