PROJECTS NOTES HOME

Wsl clock is out of sync with windows

1 The problem

Having this problem - https://stackoverflow.com/questions/65086856/wsl2-clock-is-out-of-sync-with-windows

run this in powershell to confirm it:

Get-Date; wsl date

You will notice two different times. They should be the same.

2 Possible solution

Solution is to run sudo hwclock -s command. It will sync the time. For that moment. But time will shift again when I put the laptop to sleep.

I don want to run the command manually each time. I will make a script that runs this command and put it in .bashrc so it automatically runs the script each time I launch wsl. Should be enough?

[2023-12-10 Sun] sudo hwclock -s is not an option.. it does not always work when I run it.

3 Solution that works best for me now