Categories: How-To

Hwclock command on Linux (machine clock) [Basic Guide]

The hwclock command on Linux can be used to read the machine clock or update the machine clock with the system clock and vice versa.

As stated at the beginning of the chapter, computers maintain two clocks. A so-called machine clock (hardware), is turned on when the system is inactive, and is held by a quartz crystal and battery when the computer is turned off. This battery is capable of keeping the watch even when disconnected from the electrical network for a long time.

When the computer is turned on, Linux reads the machine clock to update its system clock. It is common for there to be a small difference between these two watches.

The hwclock command has the following options:

  • -r: enter the hardware clock times with the local time zone;
  • -s: set the system clock with the hardware clock times;
  • -w: configure the hardware clock with the system clock times;
  • -c: compares the hardware clock and system clock times every 10 seconds;
  • –adjust: add or subtract time from the hardware clock to adjust it to frequency slippage;

Examples:

# hwclock -c 
hw-time system-time freq-offset-ppm tick
1571594417 1571594417.011423
1571594427 1571594427.012649 123

1

To set the Hardware clock with the system clock:

# hwclock -w

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.