6

It just struck me, when I shut down my machine and then boot it up again later, how does it know what the date and time is without checking with its servers (which it does also check with when there is an internet connection)? I am running Ubuntu GNOME 16.04 with GNOME 3.20 and I am just suddenly very curious about this.

There is probably some sort of clock in my machine, but then if I were to completely power down the machine would the clock go astray?

2
  • 1
    Panda, you have been around for some time on AskUbuntu for some time and you should already know this is off-topic because it's hardware-related question, not related to Ubuntu. Come on, man. Aug 14, 2016 at 21:42
  • 2
    @Serg: Well, I wasn't absolutely certain about it being hardware-related... That's why I asked...
    – user364819
    Aug 14, 2016 at 21:48

3 Answers 3

12

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!

10
  • How long would it take for that battery to run out?
    – user364819
    Aug 14, 2016 at 14:20
  • @ParanoidPanda - Edited. Aug 14, 2016 at 14:21
  • @ParanoidPanda - I also added some bonus material. Aug 14, 2016 at 14:29
  • Oh dear, then they should really give some sort of an indication somewhere about the timezone for the time given so that each can adapt properly. But I doubt Windows would be kind to us in that way.
    – user364819
    Aug 14, 2016 at 14:36
  • 1
    @ParanoidPanda,Android Dev you can configure Windows to use UTC, which removes the timezone problems.
    – Ángel
    Aug 14, 2016 at 15:06
5

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.

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).