打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
centos 6.5 查看时区和设置时区

 centos6.x 和centos7.x在时区方面有点差距,本文是针对centos6.x进行介绍。

其实在我的一个博文里,在安装系统的时候就可以进行时区的设置,本文介绍的是用命令进行时区查看和设置。

>>提君博客原创  http://www.cnblogs.com/tijun/  <<

使用date命令查看时区

 

[root@ltt1 ~]# date -RThu, 28 Sep 2017 00:31:54 +0800

 

我们国家的东八区(+0800)

查看clock系统配置文件

 

[root@ltt1 ~]# cat /etc/sysconfig/clock ZONE="Asia/Shanghai"

 

我的系统设置的时区为Asia/Shanghai,也就是我们国家的东八区(+0800)。

下面介绍设置时区的一种方式。

使用tzselect设置时区

[root@ltt1 sysconfig]# tzselectPlease 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 Ocean10) Pacific Ocean11) none - I want to specify the time zone using the Posix TZ format.#? 5Please 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) Taiwan10) Cyprus          27) Lebanon            44) Tajikistan11) East Timor          28) Macau            45) Thailand12) Georgia          29) Malaysia            46) Turkmenistan13) Hong Kong          30) Mongolia            47) United Arab Emirates14) India          31) Myanmar (Burma)        48) Uzbekistan15) Indonesia          32) Nepal            49) Vietnam16) Iran          33) Oman            50) Yemen17) Iraq          34) Pakistan#? 9Please select one of the following time zone regions.1) Beijing Time2) Xinjiang Time#? 1The following information has been given:    China    Beijing TimeTherefore TZ='Asia/Shanghai' will be used.Local time is now:    Thu Sep 28 00:10:57 CST 2017.Universal Time is now:    Wed Sep 27 16:10:57 UTC 2017.Is the above information OK?1) Yes2) No#? 1You can make this change permanent for yourself by appending the line    TZ='Asia/Shanghai'; export TZto 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 youcan use the /usr/bin/tzselect command in shell scripts:Asia/Shanghai

根据提示一步一步选择就可以。

提君博客原创

>>提君博客原创  http://www.cnblogs.com/tijun/  <<

注意:上面最后的几行的说明,大概意思是说,tzselect命令只是输出一个标准的TZ写法,并不生效,你还需要将这个TZ放到你的home目录下的.profile文件里

如:TZ='Asia/Shanghai'; export TZ,同时还有注销再重新登录系统,才可设置永久生效。

下面亲测进行检验一下

我当前时区和时间

[root@ltt1 ~]# date -R;cat /etc/sysconfig/clock Thu, 28 Sep 2017 00:46:39 +0800ZONE="Asia/Shanghai"

tzselect设置一个其他的时区,只给出个结果,一些步骤不再贴出

提君博客原创

The following information has been given:    AnguillaTherefore TZ='America/Anguilla' will be used.Local time is now:    Wed Sep 27 12:48:20 AST 2017.Universal Time is now:    Wed Sep 27 16:48:20 UTC 2017.Is the above information OK?1) Yes2) No#? 1You can make this change permanent for yourself by appending the line    TZ='America/Anguilla'; export TZto 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 youcan use the /usr/bin/tzselect command in shell scripts:America/Anguilla

追加

[root@ltt1 ~]# vi /etc/profile
TZ='America/Anguilla'; export TZ
[root@ltt1 ~]# source /etc/profile

结果

[root@ltt1 ~]# date -RWed, 27 Sep 2017 13:01:30 -0400[root@ltt1 ~]# cat /etc/sysconfig/clock ZONE="Asia/Shanghai"

额,可以看到 由 +0800  变成了 -0400

提君博客原创

说明成功了,就是文件内容没有更改,目前不知是什么原因。

>>提君博客原创  http://www.cnblogs.com/tijun/  <<

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
如何调整Linux系统为正确时区
linux系统修改系统时间与时区
[转]CentOS设置系统时间和时区
CentOS 7 修改时区
Django的timezone应用心得
python时区设置——pytz模块
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服