By default Linux keeps the Real Time Clock (RTC) in UTC (Universal Time Coordinated - the successor to Greenwich Mean Time) and Windows keeps the RTC in the time in the local timezone. This means that the clock has a significant error when changing between those OSs on a dual boot system.
One possibility is to make Windows use UTC for the RTC but that apparently has bugs.
Another possibility is to configure Windows to use UTC for everything, technically that works well but the displayed time will be good for London not for most other places.
To make Linux use local time in the RTC run the command "sudo timedatectl set-local-rtc true", this will solve the problem with a dual-boot desktop PC. For a laptop there is a bug in Ubuntu 20.04 which results in the kernel getting the wrong time after return from sleep (on some systems at least), it treats the RTC as being in UTC on resume and the time will be 10 or 11 hours ahead of reality for up to 30 minutes. To solve that problem you need a script to run on resume that will correct the time.
Here is an example /etc/systemd/resume-clock.service file to correct the time:
[Unit]
Description=Fix clock on resume from sleep
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/fixtime
TimeoutSec=0
StandardOutput=syslog
[Install]
WantedBy=sleep.target
Here is an example of the /usr/local/sbin/fixtime script:
#!/bin/bash
/usr/bin/sleep 5
/usr/sbin/hwclock --hctosys
After installing those files run "sudo systemctl enable resume-clock.service" and 5 seconds after resume it will get the correct time.
IS can set this up for you on demand.
Comments
0 comments
Please sign in to leave a comment.