The hwclock command enables you to view and set the hardware clock. As mentioned before, it is strongly recommended that you keep the hardware clock aligned with UTC to prevent over- correction by other operating systems.
You can also use the hwclock command to adjust the systematic drift. The systematic drift is the predictable amount of time that the hardware clock gains or loses each day, making it inaccurate and throwing it out of alignment with the system clock. The /etc/adjtime file records information about when and by how much the hardware clock is changed. The hwclock command can then consult this file to identify the drift value, which it can use to correct the clock’s time.
Syntax
The syntax of the hwclock command is:
# hwclock [options]
hwclock Command Options
The following are some of the command options used with the hwclock command.
Option | Used To |
---|---|
–set | Set the hardware clock to the provided date and time. |
-u | Set the hardware clock to UTC. |
-s | Set the system time from the hardware clock. |
–adjust | Add or subtract time from the hardware clock to account for systematic drift. |
hwclock Command Examples
1. To see the hardware clock;
# hwclock
2. To read the Hardware Clock and print the time on Standard Output:
# hwclock -r # hwclock --show
3. To set the Hardware Clock to the time given by the –date option:
# hwclock --date=""
4. To set the system time from the hardware clock:
# hwclock -s # hwclock --hctosys
5. To set the hardware clock to current system time:
# hwclock -w # hwclock --systohc
6. To reset the system time based on current timezone:
# hwclock --systz
7. To Add or subtract time from the Hardware Clock to account for systematic drift:
# hwclock --adjust
8. To Print the kernelâs Hardware Clock epoch value to standard output:
# hwclock --getepoch
9. To Set the kernel’s Hardware Clock epoch value to the value specified:
# hwclock --setepoch--epoch=1970
10. To get the version of hwclock:
# hwclock -v # hwclock --version
11. To keep hardware clock in localtime:
# hwclock --localtime
12. To disable the facilities provided by “/etc/adjtime.”:
# hwclock --noadjfile
13. To overrides the default /etc/adjtime:
# hwclock --adjfile=filename
14. To overrides the default /dev file name, which is /dev/rtc:
# hwclock -f # hwclock --rtc=filename
15. To set hardware clock year storing range:
# hwclock --badyear
16. To specify the most common epoch:
# hwclock --srm
17. To to specify the most common epoch:
# hwclock --arc
18. To test the hardware clock:
# hwclock --test
19. To debug the hardware clock:
# hwclock --debug