The time of the Linux concept

Source: Internet
Author: User
Tags epoch time unix epoch time

Linux Tuning system time zone:
Locate the appropriate time zone file/usr/share/zoneinfo/asia/shanghai
Replace the current/etc/localtime file with this file
It's time for a date to be CST.
If not, change the value of the TZ environment variable.
Many programs and commands will use the value of this variable, TZ value can have a variety of formats, the simplest way to set up is to use the Tzselect command or terminal input tz= ' CST-8 '; The export TZ is available.
However, this change only in the entry into force, if you want to permanently take effect, it is necessary to put tz= ' CST-8 '; Export TZ adds these two sentences to your. Profile.
In Linux determine the system time zone first look at the TZ environment variable, if the TZ environment variable is not set, and then read the/etc/localtime file to determine your time zone
2)/etc/sysconfig/clock file
This file controls how the hardware clocks (hardware clock) are interpreted.
The system reads the contents of the/etc/sysconfig/clock file at startup and invokes the Hwclock command to set the system clock based on the content.
The following is an explanation of the file configuration items that are forwarded:
Set the file/etc/sysconfig control how the time is interpreted by the hardware clock (hardware clocks).
Utc=true|yes|false|no-Specifies whether the time of the hardware clock is Greenway time or system local time. True or yes indicates that the hardware clock is using Greenway, while the other is local time. Preset to local time.
Arc=false|no-Specifies whether the hardware clock 1980 epoch time (typically the epoch time used by an Alpha computer using the ARC console). False or no indicates the normal UNIX epoch Time-1970. Preset use of normal UNIX epoch time
Srm=false|no-Specifies whether the hardware clock 1900 epoch time (typically using the epoch time for the Alpha computer using the SRC console). False or no indicates the normal UNIX epoch Time-1970. Preset use of normal UNIX epoch time
Zone= time Zone-the current system local time zone name, just let the time Date property tool System-config-data know the current time zone referred to by/etc/localtime, changing its value does not change the actual system time zone. The value must be the time zone file name under/usr/share/zoneinfo.
Here is a configuration for this file:
Zone= "Asia/shanghai"
Utc=false
Arc=false
Attention:
If your original set of hardware clock time is GMT to remember to change this command, remember to use 4) method to write the system time to the hardware clock, otherwise, the next boot system will be the hardware clock recorded by the GMT as the current time of Asia/shanghai.
3) Adjust the system time method
The order of the time set to August 30, 2005 is as follows:
#date-S 08/30/2005
The command to set the system time to 6:40 P.M. 0 seconds is as follows.
#date-S 18:40:00
The time set here is only set the system time, after the next reboot of the system will still read the original time from the hardware clock, so in order to make the time setting takes effect will use 4) command
If you want to synchronize with the standard time, you should use Ntpdate, and the NTP server to do a time synchronization. Similarly, the method of synchronizing the system time using 4 is also written to the hardware clock.
4) Write system time to hardware clock Comos
You can use the clock or Hwlock command, or you can set the time of the hardware clock in the BIOS.
Clock command
#clock –w
Hwlock command
# HWCLOCK–SYSTOHC
About Linux system clocks and hardware clocks:
The Linux system has two clocks, one is the system clock, the other is the hardware clock (COMOS), the hardware clock is the clock on the motherboard through the crystal oscillator, usually powered by a battery, generally can be used for about three years.
When the Linux system starts, it reads the hardware clock, sets the time of the hardware clock to the current system time, and then the system time runs independently of the hardware clock. The system clock is maintained by the Linux kernel, and the hardware clock is controlled by the crystal oscillator.

To adjust the time zone:
1. Replace the file/usr/share/zoneinfo/asia/shanghai with the/etc/localtime;
2. Change the/etc/sysconfig/clock file to the following setting.
[Email protected] default]# Cat/etc/sysconfig/clock
Zone= "Asia/shanghai"
[Email protected] default]#
Or
It is also OK to use the Tzselect command to change steps.
Date Modified
The command to set the system date to July 27, 2011 is as follows:
#date-S 07/27/2011
Modification time
The command to set the system time to 11:37 A.M. 0 seconds is as follows:
#date-S 11:37:00

Sync bios Time
Synchronize the BIOS clock and force the system time to be written to the CMOS command as follows:
#clock-W
Modification Time:
When the suspend operation is performed in VMware, the time is also stopped, and when the guest system is turned on again, the time is indeed the last time it was suspended, at which point the "hwclock-s" command can be used to synchronize to the current time.
[[Email protected] huage]# Date
Sat June 19:19:08 CST 2011
[Email protected] huage]# Hwclock
Tue June 03:59:21 PM CST-0.709332 seconds
[[email protected] huage]# hwclock-s//Time to sync the system to the BIOS
[[Email protected] huage]# Date
Tue June 15:59:28 CST 2011

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.