Linux View Settings system time zone __linux

Source: Internet
Author: User
Tags time zones local time

Regarding the concept of time zone, in fact, the junior high school geography class has already been covered. Many people know a little about it, but maybe the details are not clear. Why divide the earth into different time zones. Because the earth always rotates from west to east, the east always sees the sun before the west, and the east is always earlier than the west. The difference between the east time and the west time must be calculated not only in hours, but also in minutes and seconds. The entire earth is divided into twenty-four time zones, each of which has its own local time. In the field of international radio communications, for the sake of uniformity, a unified time is used, which is called Universal Time Coordinated (UTC). UTC is the same as Greenwich Mean Time (GMT), and is the same as the local time in London, England.

Several standards about time are shown below. You can search for them on Google and Baidu.

 

     CST: China Standard Time, this explanation may be for RedHat Linux.

     UTC: Coordinated Universal Time, also known as Coordinated Universal Time, referred to as UTC, comes from English Universal Time / French Coordinated Time "Universal Time / Temps Cordonné". The time difference between China, Hong Kong, Macau, Taiwan, Mongolia, Singapore, Malaysia, Philippines, Western Australia and UTC is +8, which is UTC + 8.

     GMT: Greenwich Mean Time (old translation of Greenwich Mean Time or Greenwich Mean Time; English: Greenwich Mean Time, GMT) refers to the standard time of the Royal Greenwich Observatory located in the suburbs of London, England, because the prime meridian Warp there.

 

Regarding the time zone distribution map, you can refer to http://www.timedate.cn/time/timezone.htm. Our country spans five time zones: East 5th District, East 6th District, East 7th District, East 8th District, and East 9th District. Generally, the east eight district time is used uniformly.

Linux view set system time zone __Linux

 

How to check the time zone of the Linux system?

 

1: Use the date command to view the time zone

[root @ db-server ~] # date -R
 
Sun, 11 Jan 2015 07:10:28 -0800
 
[root @ db-server ~] #
 
As shown in the above RFC 2822 format, the above command outputs -0800 for West Eighth District, which is the time zone where San Francisco is located in the United States. Below is the east eighth district of our country (+0800)

[root @ lnx01 ~] # date -R
 
Sun, 11 Jan 2015 23:06:02 +0800
 
 

2: View the clock system configuration file

[root @ db-server ~] # more / etc / sysconfig / clock
ZONE = "America / Los_Angeles"
UTC = true
ARC = false
 

As shown above, it indicates that the time zone set by the system is "America / Los_Angeles", which is the West Eighth District.

 

How does the Linux system set the time zone where the system is located?

Method 1: Use tzselect to set the time zone

Example, set the system time zone to Eastern Eight (Beijing time)

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

[root @ db-server ~] # source .bash_profile
 
[root @ db-server ~] # date

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.