How to Change Date and Time with ‘ hwclock ‘ in CentOS 7

A hardware clock or Real Time Clock (RTC) is an integrated circuit on the system Mother board. That is completely independent of the current state of the operating system and runs even if the computer is shutting down.  

Display the Current Date and time you can use hwclock command as shown below

[root@localhost ~]# hwclock
Mon 29 Feb 2016 11:31:36 PM IST  -0.960107 seconds
[root@localhost ~]#

To Change the Hardware clock Date and Time you can use –set and –date option with the hwclock command

hwclock –set –date “DD MMM YYYY HH:MM”

DD –         Day Tow Digit Number

MMM-      Month Three letters Abbreviation ( Such as Jan,Feb,Mar…)

YYYY –       Year Four Digit Number

HH  –       Hour Two Digit Number

MM –       Minute Two Digit Number 

[root@localhost ~]# hwclock –set –date “03 Mar 2016 23:25” –localtime
[root@localhost ~]# hwclock
Thu 03 Mar 2016 11:25:05 PM IST  -0.148128 seconds
[root@localhost ~]#


You can Synchronize  the Date and Time with Hardware clock to System clock and Vice versa. If you enable NTP (Network Time Protocol) Than the hardware clock is automatically synchronized to the system clock every 11 minutes.

Synchronize the Hardware Clock with the System Time you use hwclock command with –systohc option 

[root@localhost ~]# hwclock –systohc –localtime
[root@localhost ~]# hwclock
Tue 01 Mar 2016 12:30:13 AM IST  -0.773638 seconds
[root@localhost ~]#

 In the Above Example we set hardware clock to the current system time and keep the hardware clock in local time

 Synchronize the System Time with Hardware Clock you can use hwclock command with –hctosys option.

[root@localhost ~]# hwclock –hctosys –localtime
[root@localhost ~]# hwclock
Tue 01 Mar 2016 12:35:49 AM IST  -0.068177 seconds
[root@localhost ~]#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s