Linux time and time zone modifications

Source: Internet
Author: User
Tags time zones local time

1. Check the system time

[[Email protected] ~]# Date
Thu Dec 23:25:33 CST 2012

[[Email protected] ~]# date + "%y%m%d%h:%m:%s"
20121220 23:12:54

2. View hardware Time

The system clock is the clock in the current Linux kernel, and the hardware clock is a battery-powered clock on the motherboard that can be set in the BIOS. When Linux starts, the hardware clock reads the settings of the system clock, and the system clock is independent of the hardware.

[Email protected] ~]# Hwclock
Thu 02:57:09 PM CST-0.176702 seconds


[Email protected] ~]# clock
Thu 02:57:14 PM CST-0.575501 seconds

3. Modify the system time

[[Email protected] ~]# Date
Thu Dec 23:27:43 CST 2012
[[email protected] ~]# date-s "20121220 15:28:00"
Thu Dec 15:28:00 CST 2012
[[Email protected] ~]# Date
Thu Dec 15:28:03 CST 2012

4. Modify Hardware Time

[[email protected] ~]# hwclock 
thu Dec 03:30:58 PM CST - 0.119534 seconds
[[email protected] ~]# hwclock 
thu 11:31:08 PM cst  -0.451844 seconds

5. Synchronization between system time and hardware time

System time synchronized to hardware time: hwclock-w OR hwclock--SYSTOHC

Hardware time synchronization to system time: Hwclock-s OR hwclock--Hctosys

[[email protected] ~]# date
thu Dec 15:39:08 CST 2012
[[email protected] ~]# hwclock 
thu Dec 11:36:25 PM CST - 0.661838 seconds
[[email protected] ~]# hwclock 
thu Dec 03:39:25 PM CST - 0.090384 seconds

6. View the current time zone

[Email protected] ~]# date-r
Thu, Dec 2012 15:41:24 +0800

[Email protected] ~]# 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. Modify the current time zone

Method one, [[email protected] ~]# Timeconfig

GUI modified, only for Rhel

Method Two, modify the/etc/localtime file, the file defines the local time Zone

[Email protected] ~]# date-r
Thu, Dec 2012 15:46:51 +0800
[Email protected] ~]# Mv/etc/localtime/etc/localtime.bak
[Email protected] ~]# Cp/usr/share/zoneinfo/america/new_york/etc/localtime
[Email protected] ~]# date-r
Thu, DEC 2012 02:47:40-0500
[Email protected] ~]# 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"

The modification was successful, but the timezone in the/etc/sysconfig/clock file did not change.

Method Three, set the TZ environment variable

[[email protected] ~]# date-r
[[email protected] ~]# echo "Export Tz=asia/shanghai" >>/etc/profile
[[email protected] ~]# cat/etc/profile |grep TZ
export tz=asia/shanghai
[[email protected] ~]# date-r
thu, Dec +0800 15:54:47

$TZ environment variable has a higher priority than/etc/localtime, and after setting the Global environment variable, you cannot change the time zone even if you use Timeconfig to modify it.

8. Check the current time zone

View-5 Zone Current time

[Email protected] ~]# Zdump GMT-5
GMT-5 Thu Dec 12:59:13 GMT

With related abbreviations meaning

CST:CST can also represent the following 4 different time zones:

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

Edt-eastern Daylight Time Eastern Daylight Time

Cdt-central Daylight Time Central Daylight Time

UTC: Coordinated world time, also known as world standard Time or world coordinated time, referred to as UTC, from the English "coordinated Universal time" is called the World unification Times.


Linux time and time zone modifications

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.