Hardware clock, software clock, and fake clock reading notes
DougieLawson wrote: ↑
Wed Jul 25, 2018 9:18 pm
With a DS3231 you're much better off using the
built-in linux kernel driver which is activated by adding a simple line to /boot/config.txt
Doing your own thing with a python program is a waste of time
Well, for linux newbies, everything is hard. It took me hours to partially understand the
term dt (Device Tree). And I still don't understand thoroughly why "overlay" (over write?)
And for newbies, fiddling with low level drivers installation using sudo nano is dangerous. Actually, everything involved sudo is dangerous, I mean, for newbies.
Anyway, to appreciate the
difficulty of installing the
built in RTC DS3231 linux kernal driver
, I am reading the
Arch linux article on how to use the
driver commands, and made a summary.
way, even the
term 'kernal' scares away Rpi newbies, who have already been hopelessly spoiled by the
very sweet Windows plug and play (auto detect, auto install hardware drivers, no questions asked, or at
most some click click click, and job is done!).
Hardware clock, software clock, fake clock - ArchLinux last edited 2018aug03
Standard behavior of most operating systems is:
- 1. Set the system clock from the hardware clock on boot.
- 2. Keep accurate time of the system clock, see #Time synchronization.
Hardware clock commands
- 3. Set the hardware clock from the system clock on shutdown.
Read hardware clock
# hwclock --show
Set hardware clock from system clock
# hwclock --systohc
Software clock commands (System clock)
initial value of the
system clock is calculated from the
hardware clock, dependent on the
contents of /etc/adjtime. 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 software clock (and hardware clock?)
Set system clock directly (manual, by hand!):
# timedatectl set-time
Hardware clock time standard (UTC etc)
To query and hardware clock time
standard, eg UTC (Arch command)
$ timedatectl | grep local
RTC in local TZ: no
To change the
hardware clock time
standard to localtime, use:
# timedatectl set-local-rtc 1
To revert to the
hardware clock being in UTC, type:
# timedatectl set-local-rtc 0
UTC commands in Ubuntu
Every clock has a value that differs from real time
best representation of which being 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'
The Network Time Protocol (NTP)
is a protocol for synchronizing the
clocks of computer systems over packet-switched, variable-latency data networks.
The following are implementations of such protocol:
Network Time Protocol daemon
reference implementation of the
protocol, especially recommended to be used on time
sntp — An SNTP client that comes with NTPd. It supersedes ntpdate and is recommended in non-server environments.
systemd-timesyncd — A simple SNTP daemon that only implements a client side, focusing only on querying time
from one remote server.
OpenNTPD — Part of the
OpenBSD project and implements both a client and a server.
Chrony — A client and server that is roaming friendly and designed specifically for systems that are not online all the time
ntpclient — A simple command-line NTP client.
Fake Hardware Clock
alarm-fake-hwclock designed especially for system without battery backed up RTC, it includes a systemd service which on shutdown saves the
and on startup restores the
, thus avoiding strange time
Install fake-hwclock-gitAUR, start and enable the