centos 6.5 查看时区和设置时区
centos6.x 和centos7.x在时区方面有点差距,本文是针对centos6.x进行介绍。
其实在我的一个博文里,在安装系统的时候就可以进行时区的设置,本文介绍的是用命令进行时区查看和设置。
>>提君博客原创 http://www.cnblogs.com/tijun/ <<
使用date命令查看时区
[root@ltt1 ~]# date -R
Thu, Sep :: +
我们国家的东八区(+0800)
查看clock系统配置文件
[root@ltt1 ~]# cat /etc/sysconfig/clock
ZONE="Asia/Shanghai"
我的系统设置的时区为Asia/Shanghai,也就是我们国家的东八区(+0800)。
下面介绍设置时区的一种方式。
使用tzselect设置时区
[root@ltt1 sysconfig]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
) Africa
) Americas
) Antarctica
) Arctic Ocean
) Asia
) Atlantic Ocean
) Australia
) Europe
) Indian Ocean
) Pacific Ocean
) none - I want to specify the time zone using the Posix TZ format.
#?
Please select a country.
) Afghanistan ) Israel ) Palestine
) Armenia ) Japan ) Philippines
) Azerbaijan ) Jordan ) Qatar
) Bahrain ) Kazakhstan ) Russia
) Bangladesh ) Korea (North) ) Saudi Arabia
) Bhutan ) Korea (South) ) Singapore
) Brunei ) Kuwait ) Sri Lanka
) Cambodia ) Kyrgyzstan ) Syria
) China ) Laos ) Taiwan
) Cyprus ) Lebanon ) Tajikistan
) East Timor ) Macau ) Thailand
) Georgia ) Malaysia ) Turkmenistan
) Hong Kong ) Mongolia ) United Arab Emirates
) India ) Myanmar (Burma) ) Uzbekistan
) Indonesia ) Nepal ) Vietnam
) Iran ) Oman ) Yemen
) Iraq ) Pakistan
#?
Please select one of the following time zone regions.
) Beijing Time
) Xinjiang Time
#? The following information has been given: China
Beijing Time Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Thu Sep :: CST .
Universal Time is now: Wed Sep :: UTC .
Is the above information OK?
) Yes
) No
#? 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
根据提示一步一步选择就可以。
>>提君博客原创 http://www.cnblogs.com/tijun/ <<
注意:上面最后的几行的说明,大概意思是说,tzselect命令只是输出一个标准的TZ写法,并不生效,你还需要将这个TZ放到你的home目录下的.profile文件里
如:TZ='Asia/Shanghai'; export TZ,同时还有注销再重新登录系统,才可设置永久生效。
下面亲测进行检验一下
我当前时区和时间
[root@ltt1 ~]# date -R;cat /etc/sysconfig/clock
Thu, Sep :: +
ZONE="Asia/Shanghai"
tzselect设置一个其他的时区,只给出个结果,一些步骤不再贴出
The following information has been given:
Anguilla
Therefore TZ='America/Anguilla' will be used.
Local time is now: Wed Sep :: AST .
Universal Time is now: Wed Sep :: UTC .
Is the above information OK?
) Yes
) No
#?
You can make this change permanent for yourself by appending the line
TZ='America/Anguilla'; 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:
America/Anguilla
追加
[root@ltt1 ~]# vi /etc/profile
TZ='America/Anguilla'; export TZ
[root@ltt1 ~]# source /etc/profile
结果
[root@ltt1 ~]# date -R
Wed, Sep :: -
[root@ltt1 ~]# cat /etc/sysconfig/clock
ZONE="Asia/Shanghai"
额,可以看到 由 +0800 变成了 -0400
说明成功了,就是文件内容没有更改,目前不知是什么原因。
>>提君博客原创 http://www.cnblogs.com/tijun/ <<
centos 6.5 查看时区和设置时区的更多相关文章
- PHP 查询时区与设置时区
使用以下语句来查询当前时区设置 date_default_timezone_get() 使用以下语句设置当前时间为北京时间 date_default_timezone_set('PRC');
- CentOS 7 设置时区、日期和时间
CentOS 7 设置时区.日期和时间 changhr2013关注 2019.04.19 01:33:09字数 307阅读 139 在 CentOS 7 中,引入了一个叫 timedatectl 的设 ...
- CentOS 7: 设置时区和时间
查看当前时区和时间 $ date $ ls -l /etc/localtime 查看所有可用时区 $ timedatectl list-timezones | grep Asia 设置时区 $ tim ...
- CentOS设置时区
1.使用date命令查看当前时间 2.已软连接的方式设置时区 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- Centos7 时区的设置
Linux 系统(我特指发行版, 没说内核) 下大部分软件的风格就是不会仔细去考虑向后 的兼容性, 比如你上个版本能用这种程序配置, 没准到了下一个版本, 该程序已经不见了. 比如 sysvinit ...
- CentOS 7 修改时区例如上海时区
Linux 系统(我特指发行版, 没说内核) 下大部分软件的风格就是不会仔细去考虑向后 的兼容性, 比如你上个版本能用这种程序配置, 没准到了下一个版本, 该程序已经不见了. 比如 sysvinit ...
- Mac OS X 10.9.3 UI 设置界面无法设置时区解决
10.9.3 在选项设置里无法设置时区,表现为选择时区的点的位置后无法保存,导致系统时间错乱,解决方法是用终端设置: sudo systemsetup -gettimezone sudo system ...
- Linux 同步时间 设置时区
简化版 同步时间 #直接用域名同步中国上海时间 ntpdate -u ntp.api.bz # hwclock --hctosys 或者 # clock --hctosys hc代表硬件时间,sys代 ...
- Debian 8 设置时区和时间配置
一.设置时区 1. 执行 tzselect 2. 弹出洲级地域选项: Please identify a location so that time zone rules can be set cor ...
随机推荐
- MySQL大小写敏感的解决方案
前言:对于MySQL的大小写敏感的影响,笔者在一个小项目中深刻的体会到:当想要查询一条数据时,总是出来两条或多条,后来发现是大小写敏感造成的原因,本文就该问题提出解决方案. 1.MySQL大小写敏感的 ...
- SQL UPDATE 语句
Update 语句 Update 语句用于修改表中的数据. 语法: UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值 Person: LastName FirstName ...
- python六十四课——高阶函数练习题(一)
1.lt = ['sdfasdfa', 'ewqrewrewqr', 'dsafa12312fdsafd', 'safsadf'] --> 得到长度列表2.tp = ('TOM', 'Lilei ...
- [小米 Online Judge]找出单独出现的数字
描述: 给出N个数字.其中仅有一个数字出现过一次,其他数字均出现过两次,找出这个出现且只出现过一次的数字.要求时间和空间复杂度最小. 输入: 输入多个数字,每个数字以空格分开,回车结束 输出: 输出内 ...
- servlet是线程安全的么
servlet生命周期 三个重要方法 1 init() 进行资源的加载 2 service() 处理请求,根据请求方式,调用doGet或者doPost 3 destroy() 进行资源的释放 ser ...
- SpringBoot实战之SpringBoot自动配置原理
SpringBoot 自动配置主要通过 @EnableAutoConfiguration, @Conditional, @EnableConfigurationProperties 或者 @Confi ...
- 机器学习算法总结(十二)——流形学习(Manifold Learning)
1.什么是流形 流形学习的观点:认为我们所能观察到的数据实际上是由一个低维流行映射到高维空间的.由于数据内部特征的限制,一些高维中的数据会产生维度上的冗余,实际上这些数据只要比较低的维度就能唯一的表示 ...
- 6.oop-类和对象
一.如何抽象对象1.创建一个类2.给该描述属性 属性就是java中所有的数据类型3.给该类定义行为方法 方法的签名是:public void 方法名(){方法体} 公共的 无返回类型 二.如何使用类和 ...
- (二 -4) 天猫精灵接入Home Assistant-自动发现Mqtt设备--传感器系列
https://www.home-assistant.io/blog/2015/10/11/measure-temperature-with-esp8266-and-report-to-mqtt/ 最 ...
- # 20175329 2018-2019-2 《Java程序设计》第二周学习总结
# 学号 2018-2019-3<Java程序设计>第三周学习总结 ## 教材学习内容总结 第二三章与我们所学习的C语言有很多的相似点,在这里我想主要就以我所学习的效果来讨论一下JAVA与 ...