How does the clock keep on track after a period of the machine being off? [closed]

Solution 1:

No, it would not go astray. There is a RTC (Real Time Clock) chip:

enter image description here

On the motherboard which is powered by, in my case, a CR2032 battery:

enter image description here

Even many laptops have an internal CR2032. I discovered that when I had to replace the CPU fan in one of my laptops. Since it was such a bear to take apart, I replaced it even though it wasn't dead :)

And yes, those batteries do die after 6+ years... (Of course, your milage may vary depending on how long the computer has AC power VS. running off of only that tiny battery.)

Bonus material!

If you've ever dual booted with Windows, and aren't always connected to the internet, you'll notice that the clock is frequently wrong. That is because Ubuntu uses UTC while Windows uses LT. Therefore, they both think that the RTC's time is wrong when connected to the interent, and reset it to be correct for that OS. But then when you switch OSs, it happens again!

Solution 2:

I'm fairly certain that's why computers have a BIOS clock: so the OS can read it and stay on-time.

Turning off the machine may shut down the OS, but the computer is still powered, meaning it can still keep its hardware clock ticking. Most computers (even laptops) also have a watch battery installed, which will keep the clock going even when the rest of the machine loses power. If this battery dies, the BIOS clock will also reset.

So, the OS shuts down and stops counting. When you start it back up, it reads the hardware clock and adjusts its time accordingly (reading the timezone of the BIOS clock, adjusting for the timezone of the OS clock). The hardware clock will always be on, unless the battery is dead, so it's always counting.

Solution 3:

This is thanks to a small device inside your computer called a Real-Time Clock. It is usually powered by a small button battery and (usually) cannot be turned off except by physically taking the motherboard out and removing the button battery; therefore, no, turning off your computer would not make the clock go astray. The button battery does run out of power, but it takes a very long time (usually 10+ years).