7

Running Ubuntu in WSL2 my clock is getting screwed up somehow. And when I try to set it again using:

sudo dpkg-reconfigure tzdata

It still gets set about an hour behind the real time.

The screenshot shows the real current time in Windows, and also Windows via an RDP connection to the machine running WSL2/Ubuntu.

The purple terminal window is the Ubuntu having trouble.

Not super-great with Linux; any idea what's causing the time to be set wrong?

enter image description here

1 Answers1

15

Is there any chance the computer has been in Sleep or Hibernate, or is the WSL machine running in a VM? That was (at one point) known to cause WSL's "hardware clock" to become out-of-sync with the real/Windows time.

Reference: This Stack Overflow answer and the related Github issue.

The core issue (at least the Sleep/Hibernate issue) is fixed by the 5.10.16.3 WSL2 kernel release, which you can update to (if you aren't on it already) with wsl --update (in recent Windows releases) or via Windows Update (assuming you have allowed "other Microsoft products" to update as part of it).

However, there may still be clock drift issues, as noted in that Github issue.

If so, try a sudo hwclock -s, and if that doesn't fix it, a wsl --shutdown and restart.

NotTheDr01ds
  • 22,082