Time

From ArchWiki

Jump to: navigation, search
Article summary
This article provides an introduction to the concept of keeping time on computers in general, and describes how clocks are configured and managed in Arch Linux.
Available in languages
English
Related articles
Network Time Protocol
rc.conf

This article explains how to read and set the hardware clock (a.k.a. the Real Time Clock (RTC) or CMOS clock) and the system clock. For maintaining accurate system time, please read Network Time Protocol.

Contents

About

The hardware clock keeps values of year, month, day, hour, minute, and seconds. The hardware clock time value may either be in the localtime standard or the Coordinated Universal Time (UTC) standard. Localtime is dependent on your local time zone while UTC (aka Greenwich Mean Time) is global time and independent of time zone values. The hardware clock can only store time values and does not store information on whether localtime or UTC time is used, nor whether daylight savings time is used. Common operating systems like Windows and Mac OS will set the hardware clock dependent on your timezone (localtime), while UNIX-like operating systems can be told to use either value.

Operating systems also have a software clock (aka the system clock) that runs independent of the hardware clock. The system clock keeps track of the time, time zone, and whether or not your location uses Daylight Savings Time (DST). The Arch Linux script (/etc/rc.sysinit) sets the system clock from the hardware clock on boot, and the script (/etc/rc.shutdown) sets the hardware clock from the system clock on shutdown. Users often use NTP to keep the system clock set to the proper time.

Time Standard

You can set the time standard through the command line. You can check what you have set your Arch Linux install to use by:

$ grep ^HARDWARECLOCK /etc/rc.conf

To immediately change the hardware clock time standard, you can set localtime by (if you use Windows or Mac OS you will want to use this):

# hwclock --localtime

And to set it as UTC by:

# hwclock --utc

The time standard will also need to be entered in your Arch Linux system configuration (rc.conf) so that it will be set the next time you restart:

HARDWARECLOCK="localtime"

or

HARDWARECLOCK="UTC"
Note: GNU/Linux will change to-and-from DST when the HARDWARECLOCK setting is set to UTC, regardless of whether GNU/Linux was running at the time DST is entered or left. When the HARDWARECLOCK setting is set to localtime, GNU/Linux will not adjust the time, operating under the assumption that you dual-boot and that the other OS takes care of the DST switch. If this is not the case, the DST change needs to be made manually.

Your hardware clock and system clock time may need to be updated after this, read #Time Set.

Time Zone

Be sure that your time zone is set correctly in /etc/rc.conf, this not only is necessary for the localtime to be set correctly but also for other programs you may use. You can do this by:

$ grep ^TIMEZONE /etc/rc.conf

You can find the timezones listed in /usr/share/zoneinfo/ and then use a nearby city that corresponds to your time zone. For example:

TIMEZONE="America/Chicago"

The new timezone will be taken into effect when you set the hardware clock, see the next step.

Time Set

The hardware clock can either be set directly or from the system clock. To check the current hardware clock time and system clock time respectively:

$ hwclock --show
$ date

To set the hardware clock directly (in military time):

# hwclock --set --date "MM/DD/YYYY hh:mm:ss"

To set the system clock:

# date MMDDhhmmYYYY

The hardware clock can be set from the system clock and vice versa:

# hwclock --systohc
# hwclock --hctosys

Life, the Universe, and Time

Time. Our concept of time speaks much more to our limited perception than it does to the nature of what we observe. Time is clearly the most fertile ground for a fundamental shift in the human conception of the objective natural universe.

Time has been measured since the beginning of time, at least as a human concept. The most obvious natural marker of the passage of time is the progression of day and night. The "day" was the first known measure of time and still forms a fundamental part of timekeeping. Other cyclic natural phenomena are also historically associated with time; the word "tide" comes from a common etymological root. Even with computer timekeeping, the day is a fundamental concept. The POSIX time standard tracks time in UTC time since midnight of January 1, 1970.

As the measurement of time has improved, standard measures of time have had to be revised. The "leapyear" accounts for the fact that the Earth's orbit around the sun is not exactly 365 days. With the advent of atomic clocks in the 1960s, it became clear that the Earth's daily rotation was gradually slowing down (primarily due to tidal friction). The definition of the second in terms of cesium atom oscillations is the basis of the time standard known as International Atomic Time, or TAI.

The slow and irregular increase in the amount of time comprising a day occasionally causes problems with the POSIX definition of a day as 86400 seconds. This lead to the introduction of the "leapsecond" in 1972. Occasionally a second must be inserted into the normally defined UTC sequence in order to keep it synchronized with TAI.

Resources

Personal tools