How Time Works on Linux
Before managing time zones on Linux, you need to understand how time works on Linux. The
first thing you need to understand is that there are two main clocks in a Linux system:
• Hardware clock
This clock runs independently all the time, even when the system is
powered off. The hardware clock is called by a variety of names, including the Real Time
Clock (RTC) or the BIOS/CMOS clock.
You can use the hwclock command at the shell prompt to set the time in the hardware clock.
• System time
This clock runs via software inside the Linux kernel itself. It is driven by
an ISA timer interrupt. System time is measured as the number of seconds since 00:00:00
January 1, 1970 UTC.
The key thing to remember is that the hardware clock and the system time may not be the
same. When managing a Linux system, we are more concerned with the system time than the
time reported by the hardware clock. The role of the hardware clock is pretty basic. Its job is to
keep time when the system is powered off. The system time is synchronized to the hardware clock
time when the Linux operating system starts. After booting, Linux only uses system time. The
hardware clock is ignored.
When setting the time on your hardware clock, you should set it to one of the following:
• Universal Time Coordinated (UTC)
UTC is the standard by which the world regulates time. UTC is the current mean solar time at the
Royal Observatory in Greenwich, London, in England. Thus, UTC is also referred to as
Greenwich Mean Time (GMT).
Your local time is determined by adding or subtracting one hour to or from
UTC for each time zone you are away from UTC. For example, I live seven time zones
away from Greenwich, so my time is UTC –7. Therefore, at 10:58 a.m. my local time,
it’s 5:58 p.m. UTC.
If your hardware clock is set to UTC instead of the local time, you
need to set the
HWCLOCK directive
in the
/etc/sysconfig/clock
file to
–u.
Your Linux system will automatically calculate daylight savings time offsets according to your local time zone.
For Linux systems, it is actually preferred that you set your hardware
clock to UTC instead of local time.
• Local time
The hardware clock in most systems you will encounter will be set to local
time by default. If this is the case, the
HWCLOCK directive
in the
/etc/sysconfig/clock
file will be set to
--localtime
Setting your hardware clock to UTC is the preferred option when working with Linux systems.
Using UTC makes calculating time zone differences much easier. In fact, if you install certain
groupware applications on your Linux system, you may be required to set your hardware clock to
UTC because it makes it easier to coordinate time stamps among a large number of computers
located in different time zones.
LX0-104 Exam Objectives (M)
No comments:
Post a Comment