Skip to content

Instantly share code, notes, and snippets.

@mbaezner
Created April 22, 2021 00:28
Show Gist options
  • Save mbaezner/36a569aa09387162ff31c7867b263aaa to your computer and use it in GitHub Desktop.
Save mbaezner/36a569aa09387162ff31c7867b263aaa to your computer and use it in GitHub Desktop.
Sync Time from Windows Subsystem for Linux 2

Sync Time from Windows Subsystem for Linux 2

Linux running under Windows Subsystem for Linux 2 (WSL2) gets paused when not actively being used. This can cause the time to become of out sync with the reality, leading to package manages failing to establish encrypted connections with servers and fail to install packages. A simple fix is to install Chrony and execute it from the .bashrc file (since Linux in WSL2 does not have a standard supervisor process or serivces; e.g. no crontab for scheduled tasks.)

Install

sudo apt install chrony

Command

Add the following line to the .bashrc file:

eval "$(sudo /usr/sbin/chronyd -q &> /dev/null &)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment