时间的一致性很关键,对于日志的分析和程序的对接都至关重要!

01、tzselect 修改时区

可以使用命令 tzselect,修改时区。操作示例:

  1. $ tzselect
  2. Please identify a location so that time zone rules can be set correctly.
  3. Please select a continent or ocean.
  4. 1) Africa
  5. 2) Americas
  6. 3) Antarctica
  7. 4) Arctic Ocean
  8. 5) Asia
  9. 6) Atlantic Ocean
  10. 7) Australia
  11. 8) Europe
  12. 9) Indian Ocean
  13. 10) Pacific Ocean
  14. 11) none - I want to specify the time zone using the Posix TZ format.
  15. # 5 输入5,选择亚洲
  16. Please select a country.
  17. 1) Afghanistan 18) Israel 35) Palestine
  18. 2) Armenia 19) Japan 36) Philippines
  19. 3) Azerbaijan 20) Jordan 37) Qatar
  20. 4) Bahrain 21) Kazakhstan 38) Russia
  21. 5) Bangladesh 22) Korea (North) 39) Saudi Arabia
  22. 6) Bhutan 23) Korea (South) 40) Singapore
  23. 7) Brunei 24) Kuwait 41) Sri Lanka
  24. 8) Cambodia 25) Kyrgyzstan 42) Syria
  25. 9) China 26) Laos 43) Taiwan
  26. 10) Cyprus 27) Lebanon 44) Tajikistan
  27. 11) East Timor 28) Macau 45) Thailand
  28. 12) Georgia 29) Malaysia 46) Turkmenistan
  29. 13) Hong Kong 30) Mongolia 47) United Arab Emirates
  30. 14) India 31) Myanmar (Burma) 48) Uzbekistan
  31. 15) Indonesia 32) Nepal 49) Vietnam
  32. 16) Iran 33) Oman 50) Yemen
  33. 17) Iraq 34) Pakistan
  34. #9 输入9,选择中国
  35. Please select one of the following time zone regions.
  36. 1) east China - Beijing, Guangdong, Shanghai, etc.
  37. 2) Heilongjiang (except Mohe), Jilin
  38. 3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
  39. 4) most of Tibet & Xinjiang
  40. 5) west Tibet & Xinjiang
  41. #1 输入1,选择北京时间
  42. The following information has been given:
  43. China
  44. east China - Beijing, Guangdong, Shanghai, etc.
  45. Therefore TZ='Asia/Shanghai' will be used.
  46. Local time is now: Mon Nov 9 13:40:51 CST 2015.
  47. Universal Time is now: Mon Nov 9 05:40:51 UTC 2015.
  48. Is the above information OK?
  49. 1) Yes
  50. 2) No
  51. # 1 输入1确认
  52. You can make this change permanent for yourself by appending the line
  53. TZ='Asia/Shanghai'; export TZ
  54. to the file '.profile' in your home directory; then log out and log in again.
  55. Here is that TZ value again, this time on standard output so that you
  56. can use the /usr/bin/tzselect command in shell scripts:
  57. Asia/Shanghai

02、修改配置文件修改时区

也可以直接通过修改配置文件来变更时区。

  1. vi /etc/sysconfig/clock
  2. ZONE=Asia/Shanghai(查/usr/share/zoneinfo/Asia下面的文件)
  3. rm /etc/localtime
  4. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  #强制建立软链接
  5. 备注:修改完时区需要重启生效,查看时区可以使用命令 date -R。

03、修改同步时间

CST可视为美国,澳大利亚,古巴或中国的标准时间。
中文名
CST
概述 
CST可视为美国,澳大利
美国中部时间
Central Standard Time (USA)
中国标准时间
China Standard Time UT+8:00
古巴标准时间
Cuba Standard Time UT-4:00

UTC

协调世界时是以原子时秒长为基础,在时刻上尽量接近于世界时的一种时间计量系统

linux系统时钟有两个:

一个是硬件时钟,即BIOS时间,就是我们进行CMOS设置时看到的时间,

一个是系统时钟,是linux系统Kernel时间。当Linux启动时,系统Kernel会去读取硬件时钟的设置,然后系统时钟就会独立于硬件运作。有时我们会发现系统时钟和硬件时钟不一致,因此需要执行时间同步.

系统时钟

date命令将日期设置为2014年6月18日

----   date -s 06/18/14

将时间设置为14点20分50秒

----   date -s 14:20:50

将时间设置为2014年6月18日14点16分30秒(MMDDhhmmYYYY.ss)

----date 0618141614.30

硬件时间

hwclock/clock 命令查看、设置硬件时间

查看系统硬件时钟

hwclock  --show  或 clock  --show

设置硬件时间

hwclock --set --date="06/18/14 14:55" (月/日/年时:分:秒)

clock --set --date="06/18/14 14:55" (月/日/年时:分:秒)

同步系统及硬件时钟

下图中可以看到硬件和系统时钟相差半小时。可以使用hwclock或者clock进行同步,

硬件时钟与系统时钟同步:

# hwclock --hctosys 或者 # clock --hctosys  hc代表硬件时间,sys代表系统时间,即用硬件时钟同步系统时钟

系统时钟和硬件时钟同步:

# hwclock --systohc或者# clock --systohc  即用系统时钟同步硬件时钟

Linux服务器修改时区时间的更多相关文章

  1. 云服务器 ECS Linux 服务器修改时区的两种方式

    在云服务器 ECS Linux 系统中,以 Centos6.5 为例,可以通过如下两种方式,修改系统时区: 可以使用命令 tzselect,修改时区.操作示例: [root@localhost ~]# ...

  2. Linux怎样修改系统时间

    修改linux的时间可以使用date指令 修改日期: 时间设定成2009年5月10日的命令如下: #date -s 05/10/2009 修改时间: 将系统时间设定成上午10点18分0秒的命令如下. ...

  3. Linux服务器同步Intetnet时间

    Linux服务器同步Intetnet时间 在使用linux服务器(虚拟机)的过程中,经常会发现使用一段时间后,linux服务器的时间和我的宿主机的时间不一致,而宿主机的时间确实是internet时间, ...

  4. 设置linux服务器定时与时间服务器同步

    在一些大公司经常出现这样一个情况:公司或一些机关单位的内部业务系统的应用服务器以及数据都是做的多机集群部署而且基本都是linux系统,而且都是内部网,不与外网通讯的.这样经常就会出现一个情况,我发送任 ...

  5. 查看和修改Linux服务器的时区和时间

    一.查看和修改Linux的时区1. 查看当前时区 命令 : "date -R" 2. 修改设置Linux服务器时区方法 A 命令 : "tzselect" 方法 ...

  6. Linux永久修改系统时间和时区方法

    修改时区: 1> 找到相应的时区文件 /usr/share/zoneinfo/Asia/Shanghai 用这个文件替换当前的/etc/localtime文件. 或者找你认为是标准时间的服务器, ...

  7. linux系统修改系统时间与时区

    有装过Linux系统的人,可能都会有这样的经历,就是该机器安装windows系统时,时间正确,但是安装了linux系统后,尽管时区选择正确,也会发现系统时间不对.这是由于安装系统时采用了UTC,那么什 ...

  8. Linux服务器同步网络时间

    Linux服务器运行久时,系统时间就会存在一定的误差,一般情况下可以使用date命令进行时间设置,但在做数据库集群分片等操作时对多台机器的时间差是有要求的,此时就需要使用ntpdate进行时间同步. ...

  9. Linux下修改系统时间并写入BIOS

    我们一般使用“date -s”命令来修改系统时间.比如将系统时间设定成2005年7月26日的命令如下. #date -s 07/26/2005 将系统时间设定成下午11点12分0秒的命令如下. #da ...

随机推荐

  1. 编码策略:在ios编码中一定要少写全局变量。

    ios中全局变量默认是灰绿色的,只有少些全局变量,才能提高代码的聚合程度.才能更容易管理代码.

  2. 视图Ext.Viewport和窗口Ext.Window用法

    Viewport不需要再指定renderTo,而我们也看到Viewport确实填充了整个浏览器显示区域,并会随着浏览器显示区域大小的改变而改改.他有三个特点: 1).创建即可使用.不需要渲染,当组件在 ...

  3. [翻译] 极具动感的 FRDLivelyButton

    FRDLivelyButton https://github.com/sebastienwindal/FRDLivelyButton FRDLivelyButton is a simple UIBut ...

  4. tomcat配置管理员帐号密码

    进入tomcat目录下的conf中的tomcat-users.xml: 增加以下语句 <role rolename="admin-gui"/><role role ...

  5. Android之LogUtil

    提供debug与release的时候是否屏蔽打印信息,把信息选择性的进行保存,可以是否自动保存crash的堆栈信息.来自github上的一个开源项目,https://github.com/syxc/L ...

  6. 详解Spring中的Profile

    前言 由于在项目中使用Maven打包部署的时候,经常由于配置参数过多(比如Nginx服务器的信息.ZooKeeper的信息.数据库连接.Redis服务器地址等),导致实际现网的配置参数与测试服务器参数 ...

  7. AndEngine中文文档下载地址

    AndEngine doc  downloadhere 下载地址:http://pan.baidu.com/s/1bnjcL0V 文档是由github仓库AndEngine的代码生成. 本doc中包括 ...

  8. 使用ADB管理Andorid系统软件

    # Usageadb shell pm list packages -fadb shell pm list packages -eadb shell pm list packages -dadb sh ...

  9. Android系统file_contexts二进制与文本转换工具

    #ifdef _WIN32 #define __USE_MINGW_ANSI_STDIO 1 #endif #include <stdio.h> #include <stdlib.h ...

  10. Informatica 常用组件Source Qualifier之八 Distinct

    如果希望 PowerCenter 从源选择唯一值,您可以使用"选择相异"选项.例如,您可以使用此功能从列出总销售额的表中提取唯一客户标识.使用"选择相异"过滤器 ...