ubuntu系统怎么修改时区和时间

66次阅读
没有评论

共计 3030 个字符,预计需要花费 8 分钟才能阅读完成。

本文丸趣 TV 小编为大家详细介绍“ubuntu 系统怎么修改时区和时间”,内容详细,步骤清晰,细节处理妥当,希望这篇“ubuntu 系统怎么修改时区和时间”文章能帮助大家解决疑惑,下面跟着丸趣 TV 小编的思路慢慢深入,一起来学习新知识吧。

在 linux 计算机上,有两个时间,一个是硬件时间(bios 中记录的时间,称为 hwclock),另一个是操作系统时间(osclock)。硬件时钟由 bios 电池供电,

当计算机关机后,会继续运行,bios 电池一般可使用几年,如果没电了,那 bios 中的数据会恢复出厂设置。

硬件时间与操作系统时间的交互流程

1、开机时,操作系统从 bios 中读取硬件时间 + 时区,然后根据 osclock 的时区,转换为对应的时间。然后操作系统时间与硬件时间就独立运行,相互不影响,我们

通过应用程序获取的时间用的都是操作系统时间。这一步是开机时 os 自动完成的。

2、主机运行过程中,通过 ntp 保证 osclock 与国际原子时同步,再将 osclock 同步到 hwclock。这一步需要自己配置实现

3、关机时,osclock 写入 hwclock。这一步是关机时 os 自动完成的。不过我们要考虑异常关机的情况,当异常关机时,osclock 可能没有写入 hwclock,这就是为什

么在第 2 步中将 osclock 定时刷入 hwclock 的原因。如果不定时刷入,那 osclock 与 hwclock 差距比较大时,若异常关机,osclock 就丢掉了,再开机时,osclock 就是

错误的,在第一个 ntp 同步到来时,osclock 就一直是错误的。而且如果使用的是 ntpd,ntpd 是渐进调整,要经过多个 ntp 同步周期后才会将 osclock 调整为国际原子

时,另外,如果 osclock 与 ntp server 的时间差超过 1000 秒,那 ntp server 就不会更新 osclock 了。

ubuntu 修改时区和时间的方法

1. 首先查看时区:

codetc@webubuntu:~$ date -r
tue, 17 dec 2013 18:23:01 +0800

如果要修改时区,执行 sudo tzselect

2. 选择区域:亚洲

codetc@webubuntu:~$ sudo tzselect
[sudo] password for codetc: 
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.
#? 5

3. 选择国家:中国

please select a country.
 1) afghanistan 18) israel 35) palestine
 2) armenia 19) japan 36) philippines
 3) azerbaijan 20) jordan 37) qatar
 4) bahrain 21) kazakhstan 38) russia
 5) bangladesh 22) korea (north) 39) saudi arabia
 6) bhutan 23) korea (south) 40) singapore
 7) brunei 24) kuwait 41) sri lanka
 8) cambodia 25) kyrgyzstan 42) syria
 9) china 26) laos 43) taiwan
10) cyprus 27) lebanon 44) tajikistan
11) east timor 28) macau 45) thailand
12) georgia 29) malaysia 46) turkmenistan
13) hong kong 30) mongolia 47) united arab emirates
14) india 31) myanmar (burma) 48) uzbekistan
15) indonesia 32) nepal 49) vietnam
16) iran 33) oman 50) yemen
17) iraq 34) pakistan
#? 9

4. 选择时区:北京时间

please select one of the following time zone regions.
1) east china - beijing, guangdong, shanghai, etc.
2) heilongjiang (except mohe), jilin
3) central china - sichuan, yunnan, guangxi, shaanxi, guizhou, etc.
4) most of tibet   xinjiang
5) west tibet   xinjiang
#? 1

5. 确认验证:

the following information has been given:
 china
 east china - beijing, guangdong, shanghai, etc.
therefore tz= asia/shanghai  will be used.
local time is now: tue dec 17 18:22:10 cst 2013.
universal time is now: tue dec 17 10:22:10 utc 2013.
is the above information ok?
1) yes
2) no
#? 1
you can make this change permanent for yourself by appending the line
 tz= asia/shanghai  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:
asia/shanghai

6. 复制文件到 /etc 目录下

sudo cp /usr/share/zoneinfo/asia/shanghai /etc/localtime

7. 更新时间

sudo ntpdate time.windows.com

8. 修改时间以后,修改硬件 cmos 的时间

sudo hwclock --systohc

读到这里,这篇“ubuntu 系统怎么修改时区和时间”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注丸趣 TV 行业资讯频道。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-15发表,共计3030字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)