All Projects → stuartleeks → wsl-clock

stuartleeks / wsl-clock

Licence: MIT license
A utility to automatically correct clock drift in WSL 2 using Windows Events to detect points where clock drift may have occurred

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects
shell
77523 projects
Makefile
30231 projects
powershell
5483 projects

Labels

Projects that are alternatives of or similar to wsl-clock

Wslinstall
Install any GNU/Linux userspace in WSL
Stars: ✭ 178 (+131.17%)
Mutual labels:  wsl
Archwsl
ArchLinux based WSL Distribution. Supports multiple install.
Stars: ✭ 3,667 (+4662.34%)
Mutual labels:  wsl
cxfuse
Crossmeta FUSE Windows Port
Stars: ✭ 55 (-28.57%)
Mutual labels:  wsl
Winfetch
🛠 A command-line system information utility written in PowerShell. Like Neofetch, but for Windows.
Stars: ✭ 189 (+145.45%)
Mutual labels:  wsl
Wsl Dotfiles
My dotfiles for running an i3-based environment within the Windows Subsystem for Linux (WSL).
Stars: ✭ 211 (+174.03%)
Mutual labels:  wsl
dotfiles
My shell configuration and scripts. My "dotfiles". ... Over a decade of tuning my environments. ⌚😮🤯
Stars: ✭ 20 (-74.03%)
Mutual labels:  wsl
Dotfiles Win
🙈 oh-my-zsh on bash on windows configuration files
Stars: ✭ 167 (+116.88%)
Mutual labels:  wsl
portabledevops
A portable devops tool set on windows, easy customization of cmder/console+msys2/cygwin/wsl
Stars: ✭ 53 (-31.17%)
Mutual labels:  wsl
Emacs Wsl
Install and run Emacs with the Windows Subsystem for Linux (WSL) in Windows 10.
Stars: ✭ 234 (+203.9%)
Mutual labels:  wsl
Pengwin
A Linux distro optimized for WSL based on Debian.
Stars: ✭ 1,415 (+1737.66%)
Mutual labels:  wsl
Alpinewsl
Alpine Linux based WSL distribution. Supports multi-install. Lightest WSL distribution.
Stars: ✭ 203 (+163.64%)
Mutual labels:  wsl
Lxrunoffline
A full-featured utility for managing Windows Subsystem for Linux (WSL)
Stars: ✭ 3,005 (+3802.6%)
Mutual labels:  wsl
dotfiles
~/.dotfiles
Stars: ✭ 28 (-63.64%)
Mutual labels:  wsl
Wsl Guide
The Hitchhiker's Guide to Bash on Ubuntu on Windows!
Stars: ✭ 186 (+141.56%)
Mutual labels:  wsl
convey
Communication through a serial port or named pipe
Stars: ✭ 46 (-40.26%)
Mutual labels:  wsl
Directx Headers
Official DirectX headers available under an open source license
Stars: ✭ 173 (+124.68%)
Mutual labels:  wsl
Terminal
The new Windows Terminal and the original Windows console host, all in the same place!
Stars: ✭ 79,371 (+102979.22%)
Mutual labels:  wsl
wsl-distrod
Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability.
Stars: ✭ 1,637 (+2025.97%)
Mutual labels:  wsl
doslinux
Run Linux programs on DOS
Stars: ✭ 1,272 (+1551.95%)
Mutual labels:  wsl
memealyzer
Memealyzer is an app built to demonstrate some the latest and greatest Azure tech to dev, debug, and deploy microservice applications.
Stars: ✭ 97 (+25.97%)
Mutual labels:  wsl

wsl-clock

IMPORTANT: This is not an official solution and whilst it worked on my machine this is an unsupported workaround :-)

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

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.

For the background to this repo, see this blog post. The implementation discussed in that blog post is based on PowerShell and that implementation is still available here. The implementation has now been replaced with a program written in Go, 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

Setup

Download the ZIP file for a prebuilt release and unzip to a local folder.

After unzipping, unblock each to the .ps1 and .exe files by right-clicking, selecting 'Properties', ticking 'Unblock' and clicking 'OK':

To set up the scheduled task, run add-wslclocktask.ps1 in the content you just unzipped. This will set up a scheduled task triggered on Hibernation Resume events to run the wsl-clock.exe to check for clock drift on resuming from hibernation.

Cleanup

To remove the scheduled task, run remove-wslclocktask.ps1

Logs/Troubleshooting

The program invoked by the scheduled task logs output to ~/.wsl-clock.log

Building from source

The simplest way to build from source is to use Visual Studio Code and open as a devcontainer. This will run the development environment with the required version of Go and allow you to run make build to build the binary.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].