Handling clock drift

If your system clock is sufficiently inaccurate then you can see various authentication related issues. For example, with apt-get update you might see errors such as Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease is not valid yet. This fix for this is to reset your clock, but what caused it to drift from the correct time?

There are a number of issues reported for WSL that indicate that the clock for WSL 2 becomes inaccurate if WSL 2 is running when Windows hibernates and then resumes. The manual workaround is to run sudo hwclock -s.

If you work with WSL 2 and regularly hibernate your machine, you may prefer an automated solution. See this repo for an approach to automatically resolving this issue. If you’re interested in the background to the solution, take a look at this this blog post.