LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to set Hardware clock (https://www.linuxquestions.org/questions/linux-software-2/how-to-set-hardware-clock-4175556767/)

LinuGeek 10-21-2015 05:09 AM

How to set Hardware clock
 
Hello Experts,

I am very much confused between System clock and Hardware clock.

On one of my Linux System, BIOS Shows the time as lets say 09:00:00 Hrs. And when I boot into the Linux OS , it Shows the time as 11:00:00. Which is the correct current time set by NTP daemon.

If I adjust the BIOS time to current time which is 2 Hours ahead of the BIOS time, then in the OS the time is Extended by 2 Hours as well. :(

I see the Point here is that System clock is always (+2) But is not correct.
I wish to have the same time in BIOS as what my OS is showing.

I can check the hwclock time using following command,

cat /proc/driver/rtc

rtc_time : 09:15:47
rtc_date : 2015-10-21
rtc_epoch : 1900
alarm : 15:37:00
DST_enable : no
BCD : yes
24hr : yes
square_wave : no
alarm_IRQ : yes
update_IRQ : no
periodic_IRQ : no
periodic_freq : 1024
batt_status : okay

So i think RTC is what Hwclock in BIOS is.
I also found that the command "hwclock --systohc --localtime" will set the RTC time to current time. But this has no effect on the actual Hardware clock in BIOS.

So how do we cut out the difference between hwclock and System clock??

Any pointers would be helpful.

Thanx.


- Admin

Tonus 10-21-2015 05:19 AM

How to set Hardware clock
 
Could try, from memory, 'hwclock --hctosys' or hwclock --help to check the right syntax.

michaelk 10-21-2015 06:27 AM

The hardware or BIOS clock can be configured in the system for either UTC or local time.

If the clock is configured for UTC time by the system which is the preferred method, the displayed time difference should be your time zone offset and in your case I assume +2.0. The /etc/adjtime file is used to configure the system for the hardware clock to be either local or UTC time.

Once the hardware clock is configured for local time you then need to set it to the current time.

frankbell 10-21-2015 08:39 PM

I usually set the system clock using the date command. This link is pretty much a rewrite of the man page plus examples: http://www.computerhope.com/unix/udate.htm

Then I set the hardware clock from the system clock:

Code:

hwclock -w
There are other ways to do it, but that's the one that was easiest for me to remember.

See the hwclock and date man pages for more.

Doug G 10-21-2015 09:11 PM

If you have a systemd distribution you can use the timedatectl utility to set os time, hwclock time, date, timezone, and more.


All times are GMT -5. The time now is 02:14 PM.