fbpx hwclock Command in Linux: Read and Sync Hardware Clock | Certificação Linux

hwclock Command in Linux: Read and Sync the Hardware Clock

📅 12/06/2021 ⏱ 2 min ✍️ Uira Ribeiro
Linuxcommands
hwclock Command in Linux: Read and Sync the Hardware Clock
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

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

As mentioned at the beginning of the chapter, computers keep two clocks. One called the hardware clock, is connected when the system is idle, and is maintained by a quartz crystal and a battery when the computer is off. This battery is capable of keeping the clock running even when disconnected from the power grid for a long time.

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

The hwclock command has the following options:

  • -r: displays the hardware clock time with the local time zone;
  • -s: sets the system clock with the time from the hardware clock;
  • -w: sets the hardware clock with the time from the system clock;
  • -c: compares the hardware clock and system clock times every 10 seconds;
  • --adjust: adds or subtracts time from the hardware clock to compensate for frequency drift;

Examples:

# hwclock -chw-time      system-time         freq-offset-ppm   tick1571594417   1571594417.0114231571594427   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 enroll 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

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp