Embedded Linux system how to set TimeZone

Source: Internet
Author: User
Tags time zones

*************************************************************************************************************** ************
Easywave Time: 2014.06.08

Category: Linux kernel-timezone Settings declaration: Reprint, please keep the link

Note: If there is an error, please correct me. These are the journal articles I studied ...

*************************************************************************************************************** ************

One: What is the clock of a Linux system

The Linux clock is conceptually similar to the Windows clock that displays the current system time, but differs from windows in terms of clock classification and setup. Linux divides clocks into system clocks (Systemclock) and hardware (Real timeclock, or RTC) clocks. System time refers to the clock in the current Linux kernel, while the hardware clock is the battery-powered motherboard hardware clock on the motherboard. Since Linux has two clock systems, what kind of clock system do you use for Linux by default? Will there be a case of two system clock conflicts? These doubts and fears are justified. First, Linux does not have a default clock system. When Linux starts, the hardware clock reads the settings of the system clock, and the system clock is independent of the hardware.
From the Linux boot process, there is no conflict between the system clock and the hardware clock, but all commands (including functions) in Linux are the system clock settings used. Not only that, the system clock and hardware clock can also be asynchronous, that is, the system time and hardware time can be different. The benefits of doing so are of little significance to the average user, but are of great use to Linux network administrators. For example, to synchronize a server in a large network (spanning several time zones), if a Linux server in New York and a Linux server in Beijing, one server does not need to change the hardware clock but only temporarily set a system time, such as to set the time on the Beijing server to New York time, Two servers to complete the synchronization of the file, and then sync with the original clock. This allows for more flexible operation of the system and hardware clocks.

Two: How to set TimeZone

The first thing you need to see is whether the embedded system Rootfs already contains the Zoneinfo folder, and if not, you can go to Ubuntu10.04 's system (any version of Ubuntu) will/usr/share/ Zoneinfo the entire Zoneinfo folder to Rootfs/usr/share, so that the embedded system has timezone, as follows:

Note that this is only the first step, and this only shows that the system already contains the basic things that have this timezone. Because our time zone is in China, so choose Shanghai in Asia. The first thing to do is to find the Shanghai file as follows:

Asia folder

See the Shanghai, it is supported by the explanation. After that, you will also need to set up a link in the ETC directory of Rootfs, as follows:

After that we can see localtime this link file in Rootfs's etc directory, as shown below:

Click on the right mouse button properties can see the following information, link target:. /usr/share/zoneinfo/asia/shanghai, as shown below:

If only to do these steps, in the embedded Linux system, can not set the correct timezone, you must also set an environment variable to be able to truly implement the timezone. is to include the environment variable TZ in the Etc/profile file as follows:

Be sure to remember that the need to add TZ environment variables, timezone will only work oh. This is a problem I encountered in the work, I was so solved, do not know the friend can refer to my this blog post test to see oh ...

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.