How to set Hardware Clock Date Time using hwclock command

How to set Hardware Clock Date Time using hwclock command


hwclock is a utility for accessing the hardware clock, also referred to as the Real Time Clock (RTC). The hardware clock is independent of the operating system you use and works even when the machine is shut down. This utility is used for displaying the time from the hardware clock. 

Hardware clock is also called as BIOS clock. You can change the date and time of the hardware clock from the BIOS.

The hardware clock stores the values of: year, month, day, hour, minute, and second. It is not able to store the time standard, local time or Coordinated Universal Time (UTC), nor set the Daylight Saving Time (DST).

1. Display Hardware Clock Date and Time


Just type hwclock, which will display the date and time of your system’s hardware clock. This is the same date and time that you’ll see from the BIOS screen. You can also use option -r, or –show to display the date and time.
# hwclock
Sat 18 Aug 2018 08:26:12 AM PDT  -0.312862 seconds

# hwclock -r
Sat 18 Aug 2018 08:20:54 AM PDT  -0.109748 seconds

# hwclock --show
Sat 18 Aug 2018 08:21:12 AM PDT  -0.640982 seconds

2. Set Hardware Clock Date and Time Manually

To Set the Hardware Clock to a Specific Date and Time


The following will set the date to Aug 11th, 2013. Please note that if you don’t specify the time, it will be set to 12:00:00 AM.
# hwclock --set --date 8/19/2018

# hwclock
Sun 19 Aug 2018 12:00:04 AM PDT  -0.703489 seconds
You can also set both date and time at the same time as shown below. Please note that it will use the local time by default.
# hwclock --set --date "8/19/2018 23:10:45"

# hwclock
Sun 19 Aug 2018 11:10:48 PM PDT  -0.562862 seconds

3. Copy System Time to Hardware Time


You really want to make sure your hardware clock has the same date and time as the system clock. As you see currently there is a difference between the system clock and hardware clock time.
# date
Sat Aug 18 08:16:17 PDT 2018

# hwclock
Sat 18 Aug 2018 08:26:53 AM PDT  -0.687841 seconds
So, use the hwclock command as shown below to set the hardware clock same as system clock. 
hwclock --systohc 












No comments:

Post a Comment