System time and hardware time for Linux

Source: Internet
Author: User
Tags time zones local time

I. Concept:
The time in a Linux system is divided into system time and hardware time:
System time refers to the time in the Linux kernel;
Hardware time refers to the time that is calculated by the hardware clock on the motherboard. Different times, the method of setting is not the same.
Detailed description is as follows:
1. "System TimeandHardware Time”
system Time : In general, the time we see on the date command, all the time calls under the Linux system (except the commands that directly access hardware time) are used at this time.
Hardware Time: The motherboard on the BIOS time, the motherboard battery power to maintain the operation, the system to read this time when the boot, and according to it to set the system time (note: System startup According to the hardware time set system time of the process may exist time zone conversion, depending on the specific system and related settings).
2. "UTC Timeandlocal time”
UTC Time: Coordinated Universal8 E2 I (H7 t0 ^/^TIME World Coordination Times (also known as World standard Time, world unification time), in the general accuracy requirements, it and GMT (Greenwich Mean Time, GMT) is the same, in fact, that is to say GMT≈UTC, but UTC is calibrated by atomic clocks, more accurate.
local time: Due to different time zones, local time is generally different from UTC, and the conversion method is
local time = UTC + time zoneOrUTC = local time-time zone
Time zone East is positive, West is negative, for example, in China, local time is used in Beijing time, on the Linux display isCST(Chinese standard Time, when China standards, attention to the central United States Standard Time is also abbreviated as CST, and the CST here is not the same!) ), the time zone is East eight, which is area +8, socst=utc+ (+ 8 hours)or utc=cst-(+ 8 hours).

Two. Settings
1) How to set the system time: Date month, January 21 13:50 2015, sudo date 112113502015 Note: Date can print/set the system time. (call date directly, get local time.) If you want to get UTC time, use Date-u. When printing the system time, the date command obtains the time by calling the Clock_gettime function, and the local time is computed through the localtime file (time zone file). When the system time is set, the date command reads the localtime file (time zone file) Determine the local time zone, and then call the Clock_settime function to calculate the local times.
2) How to set the hardware time: Hwclock--set--date= "month/day/year: Min"
Note: 1) Hwclock first opens the/DEV/RTC, reads the hardware clock. 2) Open the/etc/adjtime file and use the previous records to estimate the hardware clock bias and use it to correct the current time. 3) Open the/etc/localtime time zone file, Converts the hardware time to the time of the current time zone mapping.

-R,--show read and print the hardware clock (read hardware clock and print result)
-S,--hctosys synchronizes the hardware clock to the system clock (set the time from the hardware clock)
-W,--SYSTOHC synchronizes the system clock to the hardware clock (set the hardware clock to the current system time)

Add:
Is the time that the direct call to/sbin/hwclock displayed is the time in the BIOS? Not necessarily! This depends on whether UTC is enabled in the/etc/sysconfig/clock, if UTC (Utc=true) is enabled, the time zone conversion is displayed instead of the actual time in the BIOS, and if you add the--localtime option, the BIOS will always be The actual time in the.
[12-01 19:07> ~]# Hwclock
December 07, 2009 Monday 14:28 43 sec -0.611463 seconds
[12-01 19:07> ~]# hwclock--UTC
December 07, 2009 Monday 14:28 46 sec -0.594189 seconds
[12-01 19:07> ~]# hwclock--localtime
December 07, 2009 Monday 06:28 50 sec -0.063875 seconds

RTCReal Time Clock (RTC): The RTOs is a device that is used to keep the system time in place, even when the system is turned off, and it can be timed by powering the system on the motherboard with the micro-battery.

three. Summary:We can get the time of the system through the date command, and the system time is generated by the output pulse triggered by the programmable timing/counter. Each output pulse is also called a time tick. In the operating system you can modify the kernel boot parameters in grub (tick_divider) To adjust the clock interrupt frequency, for example: We will tick_divider=10, that is, 100Hz, then there are 100 times per second tick, each clock tick is 10 milliseconds (10ms). The corresponding system time will increase by 1 per 10ms. The kernel records the total number of time ticks that are generated after the system starts by using variable jiffy. Tick_divider can use the following values: 2=500 hz4=250 hz5=200 hz8=125 hz10= 100 Hz is limited to X86 and x86_64 architectures and does not support Xen.

This article is referenced in the literature: http://blog.chinaunix.net/uid-21501855-id-3308222.html
http://jackiechen.blog.51cto.com/196075/115751/
Http://www.linuxidc.com/Linux/2014-09/107029.htm

System time and hardware time for Linux

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.