Two clocks exist in Linux computers:
1- hardware clock or bios clock or real time clock (RTC)
- maintains time while system is off
- oscillating quartz crystal in the motherboard
- it is accurate to a few seconds per day.
- it is variable under conditions of temperature.
- usually set to Greenwich Mean Time (GMT) or Universal Coordinated Time (UTC)
2- software clock or system clock
- set at startup, using hardware clock and then maintained on its own.
- managed by the OS (in this case Linux)
- it is variable under high system load and interrupt latency
- a running linux system uses the software clock for most purposes.
Note:
-in the networked world, a system that runs services across time zones, the linux system s/w clock is best set to UTC.
-but after that, they need to be aware of their time zone.
-eg: two networked systems, one in NY one in LA, have their software clock = UTC but timezone = East & Pacific reso,
-so they add / subtract appropriately to UTC when working.
-On a dual boot system also, hwclock is set as UTC to keep time mainly because the other OS (eg Windows) that are not UTC aware like Linux
-if s/w clock is UTC, set h/w to UTC also.-The system reads the hardware clock at startup and from then on uses the software clock.
-the date cmd shows and sets the software clock not the hardware clock.
-the hwclock cmd shows the hardware clock.
# hwclock --systohc -sets the h/w clock on the basis of the s/w clock
# hwclock --hctosys -sets the s/w clock on the basis of the h/w clock
-note: . h/w clock can be set using BIOS also.
NTP or Network Time Protocol
. network time protocol - a protocol to sync computer clocks over a network, usually over Internet, to UTC.
. time sync is done by sending messages to time servers.
. time returned is adjusted by a half the round trip delay, so the accuracy depends on latency in the network.
. due to latency factor, the shorter the path to the time server, the more accurate the time keeping is.
. due to the huge number of computers on the Internet, the load on the time servers can be huge.
. to ease the load on the time-servers, the time servers are organized into strata, each stratum server serving about 1000 clients.
- stratum 0 - highly accurate atomic clocks
- stratum 1 - clocks directly depending on stratum 0
- stratum 2 - get their time from stratum 1 servers and make it available to stratum 3 servers.
- stratum 3 - get their time from stratum 2 servers and then make it available to next stratum and so on...
- even stratum 4 servers are accurate to subsecond times. accuracy goes down with each strata.
-NTP Configuration
. ntp config info is maintained in /etc/ntp.conf
. ntp is managed by ntpd daemon.
-useful ntp cmds:
# system-config-time
# ntpdate <server name>
No comments:
Post a Comment