suse linux修改系统时间,linux时间和时区修改(附suse)

1、查看系统时间

[root@test3 ~]# date

Thu Dec 20 23:25:33 CST 2012

[root@test3 ~]# date +"%Y%m%d %H:%m:%S"

20121220 23:12:54

2、查看硬件时间

系统时钟是指当前Linux Kernel中的时钟,而硬件时钟则是主板上由电池供电的时钟,这个硬件时钟可以在BIOS中进行设置。当Linux启动时,硬件时钟会去读取系统时钟的设置,然后系统时钟就会独立于硬件运作。

[root@test3 ~]# hwclock

Thu 20 Dec 2012 02:57:09 PM CST  -0.176702 seconds

[root@test3 ~]# clock

Thu 20 Dec 2012 02:57:14 PM CST  -0.575501 seconds

3、修改系统时间

[root@test3 ~]# date

Thu Dec 20 23:27:43 CST 2012

[root@test3 ~]# date -s "20121220 15:28:00"

Thu Dec 20 15:28:00 CST 2012

[root@test3 ~]# date

Thu Dec 20 15:28:03 CST 2012

4、修改硬件时间

[root@test3 ~]# hwclock

Thu 20 Dec 2012 03:30:58 PM CST  -0.119534 seconds

[root@test3 ~]# hwclock --set --date="20121220 23:31:00"

[root@test3 ~]# hwclock

Thu 20 Dec 2012 11:31:08 PM CST  -0.451844 seconds

5、系统时间与硬件时间之间的同步

系统时间同步到硬件时间:hwclock  -w  OR  hwclock -- systohc

硬件时间同步到系统时间:hwclock  -s   OR  hwclock -- hctosys

[root@test3 ~]# date

Thu Dec 20 15:39:08 CST 2012

[root@test3 ~]# hwclock

Thu 20 Dec 2012 11:36:25 PM CST  -0.661838 seconds

[root@test3 ~]# hwclock -w

[root@test3 ~]# hwclock

Thu 20 Dec 2012 03:39:25 PM CST  -0.090384 seconds

6、查看当前时区

[root@test3 ~]# date -R

Thu, 20 Dec 2012 15:41:24 +0800

[root@test3 ~]# cat /etc/sysconfig/clock |grep -i zone

# The ZONE parameter is only evaluated by system-config-date.

# The timezone of the system is defined by the contents of /etc/localtime.

ZONE="Asia/Shanghai"

7、修改当前时区

方法一、[root@test3 ~]# timeconfig

界面化修改,仅适用于RHEL

方法二、修改/etc/localtime文件,该文件定义了Local Time Zone

[root@test3 ~]# date -R

Thu, 20 Dec 2012 15:46:51 +0800

[root@test3 ~]# mv /etc/localtime /etc/localtime.bak

[root@test3 ~]# cp /usr/share/zoneinfo/America/New_York /etc/localtime

[root@test3 ~]# date -R

Thu, 20 Dec 2012 02:47:40 -0500

[root@test3 ~]# cat /etc/sysconfig/clock |grep -i zone

# The ZONE parameter is only evaluated by system-config-date.

# The timezone of the system is defined by the contents of /etc/localtime.

ZONE="Asia/Shanghai"

修改成功,但/etc/sysconfig/clock文件中的timezone未变。

方法三、设置TZ环境变量

[root@test3 ~]# date -R

Thu, 20 Dec 2012 02:53:15 -0500

[root@test3 ~]# echo "export TZ=Asia/Shanghai" >>/etc/profile

[root@test3 ~]# cat /etc/profile |grep TZ

export TZ=Asia/Shanghai

[root@test3 ~]# source /etc/profile

[root@test3 ~]# date -R

Thu, 20 Dec 2012 15:54:47 +0800

$TZ环境变量的优先级要比/etc/localtime要高,并且在设置该全局环境变量后,即使使用timeconfig来修改也一样无法改变时区。

8、查看当前相应时区时间

查看-5区当前时间

[root@test3 ~]# zdump GMT-5

GMT-5  Thu Dec 20 12:59:13 2012 GMT

9、suse时间与时区的修改

suse时间的修改与redhat linux相同,具体方法参照以上操作;

suse时区的交互式界面修改方法yast---system---Date and Time找到合适的时区,确定进行修改。

10、附相关缩写含义

CST:CST同时可以代表如下 4 个不同的时区:

Central Standard Time (USA) UT-6:00

Central Standard Time (Australia) UT+9:30

China Standard Time UT+8:00

Cuba Standard Time UT-4:00

可见,CST可以同时表示美国,澳大利亚,中国,古巴四个国家的标准时间。

EDT - Eastern Daylight Time 东部夏令时间

CDT - Central Daylight Time 中部夏令时间

UTC:协调世界时,又称世界标准时间或世界协调时间,简称UTC,从英文“Coordinated Universal Time” 称为世界统一时间。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值