First, you run the command date to show the current date and time on your Linux machine:
# date
Wed Sep 19 10:11:01 CST 2018
Wed Sep 19 10:11:01 CST 2018
It's wrong; the correct time should be 10:16. It's five minutes behind.
You run the following command to show the hardware date and time:
# hwclock --show
Wed 19 Sep 2018 10:16:34 AM CST -1.010401 seconds
Wed 19 Sep 2018 10:16:34 AM CST -1.010401 seconds
It turns out that the hardware date and time is correct! So you'd like to synchronize system time to hardware clock on your Linux box. In other words, you want to set the system time to the hardware clock.
Here's the command:
# hwclock --hctosys
Run date again immediately to see the time change:
# date
Wed Sep 19 10:17:01 CST 2018
Wed Sep 19 10:17:01 CST 2018
Shortly, run date again to make sure the clock is really running!
# date
Wed Sep 19 10:17:14 CST 2018
Wed Sep 19 10:17:14 CST 2018
Luckily our hardware date and time on the Unix box is correct. Suppose it is wrong, what do you do? If this happens to me, let me know and I'll find a solution for you.
Questions? Let me know!