You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Convert to Go implementation, with the following advantages:
* The application runs as a windowless app so there is no longer the flash of a powershell window when the task runs
* The logic has been updated to test for a running WSL v2 distro before checking whether to reset the clock (rather than _any_ running distro). This removes the potential for spinning up a WSL 2 distro when there wasn't one running (i.e. when there was no need to reset the clock)
* The logic now uses an existing running distro for executing the time checks and reset steps, rather than the default distro. This avoids situations where an extra distro may have been started, as well as avoiding issues when the default distro was configured as WSL v1
$(error This target can only be run outside of the devcontainer as it mounts files and this fails within a devcontainer. Don't worry all it needs is docker)
Copy file name to clipboardExpand all lines: README.md
+7-22Lines changed: 7 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,15 @@
2
2
3
3
**IMPORTANT: This is not an official solution and whilst it worked on my machine this is an unsupported workaround :-)**
4
4
5
-
There is an issue with WSL where the clock in WSl isn't updated when the host resumes from sleep/hibernate. E.g. [this issue](https://github.com/microsoft/WSL/issues/4245)
5
+
There is an issue with WSL where the clock in WSL isn't updated when the host resumes from sleep/hibernate. E.g. [this issue](https://github.com/microsoft/WSL/issues/4245)
6
6
7
7
This repo has a workaround that creates a scheduled task that is triggered by Windows Events for resuming from sleep/hibernation. When the scheduled task executes it resets the clock in the WSL VM.
8
8
9
-
For the background to this repo, see [this blog post](https://stuartleeks.com/posts/fixing-clock-skew-with-wsl-2/)
9
+
For the background to this repo, see [this blog post](https://stuartleeks.com/posts/fixing-clock-skew-with-wsl-2/). The implementation discussed in that blog post is based on PowerShell and that implementation is still available [here](https://github.com/stuartleeks/wsl-clock/tree/powershell). The implementation has now been replaced with a program written in Go, with the following advantages:
10
+
11
+
* The appliation runs as a windowless app so there is no longer the flash of a powershell window when the task runs
12
+
* The logic has been updated to test for a running WSL v2 distro before checking whether to reset the clock (rather than _any_ running distro). This removes the potential for spinning up a WSL 2 distro when there wasn't one running (i.e. when there was no need to reset the clock)
13
+
* The logic now uses an existing running distro for executing the time checks and reset steps, rather than the default distro. This avoids situations where an extra distro may have been started, as well as avoiding issues when the default distro was configured as WSL v1
10
14
11
15
## Setup
12
16
@@ -18,23 +22,4 @@ To remove the scheduled task, run `remove-wslclocktask.ps1`
18
22
19
23
## Logs/Troubleshooting
20
24
21
-
The script invoked by the scheduled task logs output to `~/.wsl-clock.log`
22
-
23
-
## Known issues
24
-
25
-
### Fails if default distribution is configured for WSL 1
26
-
27
-
The `update-clock.ps1` script executes the `hwclock` against the default distro. If that distro is configured to run under WSL 1 then it will result in the following error as `hwclock` isn't supported on WSL 1 (and WSL 1 isn't executing in the lightweight VM for WSL 2 so this wouldn't have any effect anyway)
28
-
29
-
```log
30
-
hwclock: Cannot access the Hardware Clock via any known method.
31
-
hwclock: Use the --debug option to see the details of our search for an access method.
32
-
```
33
-
34
-
See <https://github.com/microsoft/wsl/issues/193>.
35
-
36
-
Possible workarounds:
37
-
38
-
* change your default distro to a distro that is configured for WSL 2
39
-
* change your default distro to run on WSL 2
40
-
* modify your copy of the script to specify a distro via `-d` parameter for `wsl` when it runs `hwclock`
25
+
The program invoked by the scheduled task logs output to `~/.wsl-clock.log`
schtasks /Create /TN wsl-clock /TR $taskCommand/SC ONEVENT /EC System /MO "*[System[Provider[@Name='Microsoft-Windows-Kernel-Power'] and (EventID=107 or EventID=507)]]"/F
0 commit comments