Linux system modifies CST time zone

Source: Internet
Author: User
Tags cst time

=================================================
[Email protected] ~]# date-r
Fri, Nov 2014 08:35:37 +0800
[Email protected] ~]# cat/etc/sysconfig/clock
# The time zone of the system is defined by the contents of/etc/localtime.
# This file was only for evaluation by System-config-date, does notrely on its
# contents elsewhere.
Zone= "Asia/shanghai"
[Email protected] ~]#
=================================================
Date Modified:


The order of the time set to May 10, 2009 is as follows:
#date-S 05/10/2009
Modification Time:
The command to set the system time to 10:18 A.M. 0 seconds is as follows.
#date-S 10:18:00
=================================================
The Linux system modifies the CST time zone:
=================================================
Initial time: September 14, 2012 Friday 18:15:33EDT[Email protected] ~]# mv/etc/localtime/etc/localtime.bak[[email protected] ~]# ln-s/usr/share/zoneinfo/asia/ Shanghai/etc/localtime[[email protected] ~]# Date Modified: September 15, 2012 Saturday 18:25:00CST
=================================================
Modify Command: Tzselect
Save: Hwclock-w
=================================================
Reason analysis of system time change

Linux has two types of time, one is the system time, and the other is the hardware time (BIOS time).

Each time the system starts, it reads the BIOS time and assigns it to the system time. The system time is then run independently, and the BIOS time does not change.

There are two representations of the BIOS time. One is expressed in localtime, and one is expressed in UTC. The specific view can be done by hwclock–debug, which outputs the current hardware time representation.


The following examples illustrate the changes in system time in various situations:

1. When Hwclock is set to Utc=true in Localtime,/etc/sysconf/clock, the system time after reboot is 8 hours ahead of the BIOS time.

2. When Hwclock is set to Utc=false in Localtime,/etc/sysconf/clock, the system time does not change relative to bios time after reboot

3. When Hwclock is set to Utc=true in Utc,/etc/sysconf/clock, there is no change in the system time after reboot relative to BIOS time

4. When Hwclock is set to Utc=false in Utc,/etc/sysconf/clock, the system time after reboot is delayed by 8 hours relative to BIOS time.

As shown in the following:

/etc/sysconf/clock in Utc=true

/etc/sysconf/clock in Utc=false

Hardware Time LocalTime

8 hours prior to system time after reboot compared to BIOS time

No change in system time

Hardware time UTC

No change in system time

8 hours after system time after reboot relative to BIOS time


It can be seen that when the BIOS time setting type and the settings in the/etc/sysconf/clock are inconsistent, it causes system time errors at system startup.

If there are scripts that implement time synchronization, but run after the system starts. Although the time synchronization can synchronize the system time to the correct time, due to the previous system time error setting, there will be an error interval, this time interval may affect the system time-dependent program.

Countermeasures: The root cause of this problem is that the type of hardware time and the settings in/etc/sysconf/clock are inconsistent. Therefore, we will increase the synchronization of hardware time in the time synchronization script, which can solve this problem.

Note:

UTC time: World coordinated Time (Universal-time COORDINATED,UTC), which is 0 timezone

CST Time: CST China utc+8:00 Time (Beijing time), this is the localtime of the time zone we belong to.

2. About the time zone settings:

In order to ensure the correct time, the time zone should be set correctly. Set up correctly only to make time better understood and other aspects of maintenance.

Setup method:

1. Set the time zone manually:

Example: Setting the time of the East eight zone

Ln-sf/usr/share/zoneinfo/asia/shanghai/etc/localtime

Edit/etc/sysconfig/clock in zone= "Asia/shanghai"

2. Use graphical command settings

System-config-date (mostly limited to redhat and CentOS) or using Tzselect, follow the command prompts.
==================================================================http://blog.sina.com.cn/s/blog_4ce992f40101e2g1.html

Linux system modifies CST time zone

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.