2012-10-26

Typos

← Older revision

Revision as of 05:47, 26 October 2012

Line 22:

Line 22:

'''Hardware clock''' (a.k.a. the Real Time Clock (RTC) or CMOS clock) stores the values of: Year, Month, Day, Hour, Minute, and the Seconds.  It does not have the ability to store the time standard (localtime or UTC), nor whether DST is used.

'''Hardware clock''' (a.k.a. the Real Time Clock (RTC) or CMOS clock) stores the values of: Year, Month, Day, Hour, Minute, and the Seconds.  It does not have the ability to store the time standard (localtime or UTC), nor whether DST is used.



'''System clock''' (a.k.a. the software clock) keeps track of: Time, Time Zone, and DST if applicable. It is calculated by the Linux kernel as the number of seconds since midnight January 1st 1970 UTC. The initial value of the system clock is calculated from the hardware clock, dependent on the value of the HARDWARECLOCK variable defined in {{ic|/etc/rc.conf}}.  After boot-up has completed the system clock runs independently of the hardware clock. The Linux kernel keeps track of the system clock by counting timer interrupts.

+

'''System clock''' (a.k.a. the software clock) keeps track of: Time, Time Zone, and DST if applicable. It is calculated by the Linux kernel as the number of seconds since midnight January 1st 1970
,
UTC. The initial value of the system clock is calculated from the hardware clock, dependent on the value of the HARDWARECLOCK variable defined in {{ic|/etc/rc.conf}}.  After boot-up has completed the system clock runs independently of the hardware clock. The Linux kernel keeps track of the system clock by counting timer interrupts.

=== Read clock ===

=== Read clock ===

Line 57:

Line 57:

== Time standard ==

== Time standard ==



There are two time standards: '''localtime''' and '''C'''oordinated '''U'''niversal '''T'''ime ('''UTC''').  The localtime standard is dependent on the current ''time zone'', while UTC is the ''global'' time standard and is independent of time zone values.  Though conceptually different, UTC is also known as GMT.

+

There are two time standards: '''localtime''' and '''C'''oordinated '''U'''niversal '''T'''ime ('''UTC''').  The localtime standard is dependent on the current ''time zone'', while UTC is the ''global'' time standard and is independent of time zone values.  Though conceptually different, UTC is also known as GMT
(Greenwich Mean Time)
.



The standard used by hardware clock (CMOS clock, the time that appears in BIOS) is defined by operating system. By default, Windows uses localtime, Mac OS uses UTC, and UNIX-like operating systems vary. An OS that uses UTC standard, generally, will consider CMOS (hardware clock) time a UTC time (GMT,
Greenwitch
time) and make an adjustment to it while setting System time on boot according to your time zone.

+

The standard used by hardware clock (CMOS clock, the time that appears in BIOS) is defined by
the
operating system. By default, Windows uses localtime, Mac OS uses UTC, and UNIX-like operating systems vary. An OS that uses
the
UTC standard, generally, will consider CMOS (hardware clock) time a UTC time (GMT,
Greenwich
time) and make an adjustment to it while setting
the
System time on boot according to your time zone.



When using Linux it is beneficial to have the hardware clock set to the UTC standard and made known to all operating systems.  Defining the hardware clock in Linux as UTC means that Daylight
Savings
Time will automatically be accounted for.  If using the localtime standard the system clock will not be changed for DST occurrences assuming that another operating system will take care of the DST switch (and provided no NTP agent is operating).

+

When using Linux it is beneficial to have the hardware clock set to the UTC standard and made known to all operating systems.  Defining the hardware clock in Linux as UTC means that Daylight
Saving
Time will automatically be accounted for.  If using the localtime standard the system clock will not be changed for DST occurrences assuming that another operating system will take care of the DST switch (and provided no NTP agent is operating).

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

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

Line 75:

Line 75:

# hwclock -w --utc

# hwclock -w --utc



These will generate {{ic|/etc/adjtime}} automatically
,
no further configuration is required.

+

These will generate {{ic|/etc/adjtime}} automatically
;
no further configuration is required.



During kernel startup, at the point when the RTC driver is loaded, the system clock may be set from the hardware clock.  Whether this occurs or not depends on the hardware platform, the version of the kernel and kernel build options. If this does occur, at this point in the boot sequence, the hardware clock time is assumed to be UTC and the value of {{ic|/proc/sys/class/rtcN/hctosys}} (N=0,1,2,..) will be set to 1. Later during execution of {{ic|/etc/rc.sysinit}}, the system clock is set again from the hardware clock dependent on the value of HARDWARECLOCK. Hence, having the hardware clock using localtime may cause some unexpected behavior during the boot sequence; e.g system time going backwards which is always a bad idea.

+

During kernel startup, at the point when the RTC driver is loaded, the system clock may be set from the hardware clock.  Whether this occurs or not depends on the hardware platform, the version of the kernel and kernel build options. If this does occur, at this point in the boot sequence, the hardware clock time is assumed to be UTC and the value of {{ic|/proc/sys/class/rtcN/hctosys}} (N=0,1,2,..) will be set to 1. Later during execution of {{ic|/etc/rc.sysinit}}, the system clock is set again from the hardware clock dependent on the value of HARDWARECLOCK. Hence, having the hardware clock using localtime may cause some unexpected behavior during the boot sequence; e.g system time going backwards
,
which is always a bad idea.

=== UTC in Windows ===

=== UTC in Windows ===

Line 126:

Line 126:

== Time Skew ==

== Time Skew ==



Every clock has a value that differs from ''real time'' (the best representation of which being [[Wikipedia:International Atomic Time|International Atomic Time]])
,
no clock is perfect.  A quartz based electronic clock keeps imperfect time, but maintains a consistent inaccuracy. This base 'inaccuracy' is known as 'time skew' or 'time drift'.

+

Every clock has a value that differs from ''real time'' (the best representation of which being [[Wikipedia:International Atomic Time|International Atomic Time]])
;
no clock is perfect.  A quartz
-
based electronic clock keeps imperfect time, but maintains a consistent inaccuracy. This base 'inaccuracy' is known as 'time skew' or 'time drift'.

When the hardware clock is set with {{ic|hwclock}}, a new drift value is calculated in seconds per day. The drift value is calculated by using the difference between the new value set and the hardware clock value just before the set, taking into account the value of the previous drift value and the last time the hardware clock was set. The new drift value and the time when the clock was set is written to the file {{ic|/etc/adjtime}} overwriting the previous values. The hardware clock can be adjusted for drift when the command {{ic|hwclock --adjust}} is run; this occurs by default on shutdown if the {{ic|hwclock}} daemon is enabled.

When the hardware clock is set with {{ic|hwclock}}, a new drift value is calculated in seconds per day. The drift value is calculated by using the difference between the new value set and the hardware clock value just before the set, taking into account the value of the previous drift value and the last time the hardware clock was set. The new drift value and the time when the clock was set is written to the file {{ic|/etc/adjtime}} overwriting the previous values. The hardware clock can be adjusted for drift when the command {{ic|hwclock --adjust}} is run; this occurs by default on shutdown if the {{ic|hwclock}} daemon is enabled.



{{Note|If the hwclock has been set again less than 24 hours after a previous set, the drift is not recalculated as {{ic|hwclock}} considers the elapsed time period too short to accurately calculate the drift. It may be worth occasionally to stay in Linux so it gets calculated}}

+

{{Note|If the hwclock has been set again less than 24 hours after a previous set, the drift is not recalculated as {{ic|hwclock}} considers the elapsed time period too short to accurately calculate the drift. It may be worth occasionally to stay in Linux so it gets calculated
.
}}

If the hardware clock keeps losing or gaining time in large increments, it is possible that an invalid drift has been recorded. This can happen if you have set the hardware clock time incorrectly or your [[#Time Standard|time standard]] is not synchronized with a Windows or Mac OS install.  The drift value can be removed by removing the file {{ic|/etc/adjtime}}, then set the correct hardware clock and system clock time, and check if your [[#Time Standard|time standard]] is correct.

If the hardware clock keeps losing or gaining time in large increments, it is possible that an invalid drift has been recorded. This can happen if you have set the hardware clock time incorrectly or your [[#Time Standard|time standard]] is not synchronized with a Windows or Mac OS install.  The drift value can be removed by removing the file {{ic|/etc/adjtime}}, then set the correct hardware clock and system clock time, and check if your [[#Time Standard|time standard]] is correct.

Show more