Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

/sys/class/rtc

FieldValue
SubsystemRTC class core, drivers/rtc/ (obj-$(CONFIG_RTC_CLASS) += rtc-core.o, torvalds/linux master)
Config gateCONFIG_RTC_CLASS (obj line verified against torvalds/linux master 2026; hctosys additionally reports CONFIG_RTC_HCTOSYS per the ABI text)
ABI documentationDocumentation/ABI/testing/sysfs-class-rtc (11 What entries); one driver-specific file exists (Documentation/ABI/testing/sysfs-class-rtc-rtc0-device-rtc_calibration)
Since2.6.17 (class dir, rtcX, date, name, since_epoch, time); 2.6.20 (wakealarm); 2.6.24 (max_user_freq); 2.6.32 (hctosys); 4.6 (offset); 4.16 (range)
Live (5.10.134 host)class absent: no /sys/class/rtc directory, no RTC device registered in the container
Ledger IDSYSC-rtc

What it represents

One directory per real-time clock, rtcX, exposing the hardware clock that keeps time across reboots. The read side answers “what does the RTC say”: date (YYYY-MM-DD), time (24-hour hh:mm:ss), since_epoch (seconds), name, plus hctosys – 1 if this RTC provided the system time at boot via CONFIG_RTC_HCTOSYS – and range (valid seconds-from-epoch interval, [min, max], 4.16). The write side is the wakeup story: wakealarm takes an epoch timestamp by default, a leading + for seconds-in-the-future, or += for seconds ahead of the current alarm; it is a one-shot wakeup, so it must be reset after each wake for daily alarms. max_user_freq bounds the interrupt rate an unprivileged user may request, and offset (ppb, 4.6) reads/writes the firmware clock adjustment, visible only when the driver supports offset adjustment.

Relationship to the device model

/sys/class/rtc/rtcX is a class view over an RTC device under /sys/devices/...; the attrs cache records a rtc0/device/rtc_calibration path, showing driver-specific attributes appearing under the device/ link (the one driver-specific ABI file documents exactly such an attribute). The RTC’s char-device face (/dev/rtcN with its ioctl API) is documented separately in Documentation/ABI/testing/rtc-cdev (cached). Time-adjacent siblings in this encyclopedia: ptp (hardware timestamps, not wall time), pps (pulse discipline), timecard (GNSS-disciplined appliance clock).

Attributes

AttributeR/WUnit/formatConditional?Source
rtcX/dateROYYYY-MM-DDalwaysABI testing sysfs-class-rtc (2.6.17)
rtcX/timeROhh:mm:ss, 24-houralwaysABI testing sysfs-class-rtc (2.6.17)
rtcX/since_epochROseconds since the epochalwaysABI testing sysfs-class-rtc (2.6.17)
rtcX/nameROname of this RTCalwaysABI testing sysfs-class-rtc (2.6.17)
rtcX/hctosysRO1 if RTC set system time at boot (CONFIG_RTC_HCTOSYS), else 0alwaysABI testing sysfs-class-rtc (2.6.32)
rtcX/rangeROvalid range as [min, max] seconds from epochalwaysABI testing sysfs-class-rtc (4.16)
rtcX/wakealarmRWepoch seconds, or +N seconds ahead, or +=N ahead of current alarm; one-shotalwaysABI testing sysfs-class-rtc (2.6.20)
rtcX/max_user_freqRWmaximum interrupt rate for unprivileged users (Hz)alwaysABI testing sysfs-class-rtc (2.6.24)
rtcX/offsetRWparts per billion; positive makes a day pass more slowlyonly if driver supports offset adjustmentABI testing sysfs-class-rtc (4.6)

Safety and writes

wakealarm programs hardware that can wake the machine from power-off or suspend – a wrong write either fails or schedules an unwanted wakeup, and by design the alarm is one-shot. offset and max_user_freq change clock discipline and interrupt policy; max_user_freq exists precisely to cap what unprivileged users may do with RTC interrupts. Reads are safe. No capability requirements are stated in the ABI; in practice writes need root or udev-granted permissions.

References

  • Documentation/ABI/testing/sysfs-class-rtc, Documentation/ABI/testing/rtc-cdev, Documentation/ABI/testing/sysfs-class-rtc-rtc0-device-rtc_calibration (cached copies; online: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-rtc)
  • drivers/rtc/Makefile (torvalds/linux master; fetched obj line)
  • source-cache/sysfs-attrs.json (11 rtc paths incl. the driver-specific rtc0/device/rtc_calibration)
  • Ledger row SYSC-rtc; /sys/class/rtc absent per source-cache/live-sys/class-list.txt
  • Sibling pages: ptp, pps, timecard