Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2: Clock skewed? #4677

Closed
jordansissel opened this issue Nov 14, 2019 · 25 comments
Closed

WSL2: Clock skewed? #4677

jordansissel opened this issue Nov 14, 2019 · 25 comments
Labels
duplicate needs-investigation likely actionable and/or needs more investigation

Comments

@jordansissel
Copy link

jordansissel commented Nov 14, 2019

This is found on WSL2.

Please fill out the below information:

  • Your Windows build number: (Type ver at a Windows Command Prompt)

Version 1903 Build 19018.1

  • What you're doing and what's happening: Clock way off.

  • What's wrong / what should be happening instead: Clock should be in sync with the host.

Windows taskbar clock says 5:22pm
WSL Linux (Ubuntu) date: says 05:09:23 PST

The clock appears to be about 12 hours 13 minutes off? I don't see any obvious ways to resolve this as ntpdate is not installed by default, there's no systemd-style init process that would run ntpd/etc.

The net impact is that time-sensitive things like credential or request signing will all appear expired by the receiver because my requests are signed "12 hours ago" ;)

Thoughts?

@jordansissel
Copy link
Author

jordansissel commented Nov 14, 2019

wsl --shutdown seems to be a workaround:

% date                                    
Wed Nov 13 08:31:08 PST 2019              
% exit
PS C:\Users\whack> wsl --shutdown         
PS C:\Users\whack> wsl                    
% date                                    
Wed Nov 13 20:44:00 PST 2019              

@benhillis
Copy link
Member

benhillis commented Nov 14, 2019

You should also be able to use sudo hwclock -s from within the Linux environment.

@therealkenc
Copy link
Collaborator

Fair to say we're calling this different than #4245 (message)? Asking because the other one is tag fixininsiders, and I've lost the script on what was (contrast wasn't) addressed in 18970.

@benhillis
Copy link
Member

@therealkenc - Specifically large skews when resuming from sleep should be fixed, but small skews that accumulate during runtime may still be an issue.

@jishi
Copy link

jishi commented Dec 18, 2019

This is still a problem in Microsoft Windows [Version 10.0.19037.1]

The machine have been running WSL2 for some days, the clock in WSL2 is:

07:59 $ date
Tue 17 Dec 2019 08:03:49 AM CET

And in windows

C:\Users\jayja>date /t                                                                                                  2019-12-18                                                                                                                                                                                                                                      C:\Users\jayja>time /t                                                                                                  15:15      

This is running the debian distro which supposedly has a hwclock.sh service running, but doesn't seem to sync. Running sudo hwclock -s manually does sync the time, so maybe it's a distro problem?

@vbaderks
Copy link

vbaderks commented Feb 1, 2020

Just updated to Windows 10 build 19041.21 to start to use WSL-2
I am getting a warning on WSL-2 when building a C++ project on a NTFS drive from withing WSL-2:

make[2]: Warning: File 'samples/convert.cpp/CMakeFiles/convert-cpp.dir/depend.make' has modification time 0.022 s in the future
make[2]: warning: Clock skew detected. Your build may be incomplete.

WSL-1 has never reported these warnings on the same configuration.

@JurrianFahner
Copy link

I need to set the time every time my laptop was in hibernate.
Can something done, so the time within WSL has an auto sync capability with the host.

Workaround for me is to use ntpdate, but I think it should not needed. To work properly.

image

@rupor-github
Copy link

Windows 10 build 19041.153 attempting to use WSL2, files are on Windows file system (not rootfs):

-- Build files have been written to: /mnt/e/projects/misc/wsl-ssh-agent/release
make: Warning: File 'Makefile' has modification time 0.6 s in the future
make[1]: Warning: File 'CMakeFiles/Makefile2' has modification time 0.65 s in the future
make[2]: Warning: File 'CMakeFiles/bin_agent.dir/progress.make' has modification time 0.61 s in the future
Scanning dependencies of target bin_agent
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
make[2]: Warning: File 'CMakeFiles/bin_agent.dir/progress.make' has modification time 0.51 s in the future
[100%] Building wsl-ssh-agent-gui...
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
[100%] Built target bin_agent
make[1]: warning:  Clock skew detected.  Your build may be incomplete.

@firewave
Copy link

That seems to be an Hyper-V issue instead of an WSL one.

I have had issues with time on Hyper-V instances ever since. Any time I wake up my machine from sleep I have to manually run ntpdate to get the proper time. I tried setting up the ntp service, but that didn't seem to work at all (might have been my fault, but I used the default configuration and got no errors and no time synchronization at all). Rebooting the instance fixes it but IIRC the hardware clock sync is performed during that.

@therealkenc therealkenc added the needs-investigation likely actionable and/or needs more investigation label Jun 3, 2020
@firewave
Copy link

firewave commented Jun 4, 2020

While checking dmesg for my WSL 2 Kali instance I saw the following:

[    0.533293] hv_utils: cannot register PTP clock: 0

@Justin-DynamicD
Copy link

adding that I see this issue as well. I don't see a clear pattern between shutdown vs hibernate, but occasionally clock sensitive operations will fail until I re-sync (AWS or Azure CLI for example).

@MauriceS-gti
Copy link

I still see this issue using Windows 10/2004 build 19041.329. HOURS of difference:

PS C:\src\cs> date
Friday, June 19, 2020 11:40:07 AM
[/workspaces]$ date [docker-native:localhost]
Thu Jun 18 21:30:29 MDT 2020

@gbro3n
Copy link

gbro3n commented Jul 24, 2020

To add this is causing problems when running AWS cli commands when my Windows machine running WSL2 has slept.

For example:

aws ecr get-login-password

Results in an error like

(InvalidSignatureException) when calling the GetAuthorizationToken operation: Signature expired: <DATE> is now earlier than <DATE> (<DATE> - 15 min.)

@nbdd0121
Copy link

nbdd0121 commented Oct 5, 2020

@benhillis Running sudo hwclock on WSL2 gives a drifted clock, different from NTP & Windows Time.

$ sudo hwclock && date && cmd.exe /c time
2020-10-05 23:33:43.950559+01:00
Mon 05 Oct 2020 11:33:50 PM BST
The current time is: 23:33:50.09
Enter the new time:

EDIT: WSL2 uptime is 5 days without sleep.

@frke242
Copy link

frke242 commented Dec 4, 2020

Microsoft Windows [Version 10.0.18363.1198]

When I try to build with cmake I get the following warning:
Run Build Command(s):/usr/sbin/make cmTC_6952b/fast && make: Warning: File 'Makefile' has modification time 0.53 s in the future

I tried building both in the shared filesystem, i.e. /mnt/c and in my home folder in the wsl2 installation. Same issue.

Running date +%T.%N && cmd.exe /c time gives:
08:10:27.146163000
The current time is: 8:10:27,79

@gkochera
Copy link

gkochera commented Jan 19, 2021

Running 19041.746 with Ubuntu 20.04.1 LTS and GNU Make 4.2.1

Tried all the mentioned possible fixes included in this thread including rebooting, wsl --shutdown, and the shell commands listed. The clock in W10 and Ubuntu are definitely at least to the second matched up.

Still get this error when running make. Haven't observed it with other utilities yet.

UPDATE: I was able to discern that the clock skew is about 0.43 to 0.45 seconds. I can sync windows time and try to 'make' right after, and the issue is still present.

@nbdd0121
Copy link

I wrote a program to workaround this problem: https://github.com/nbdd0121/wsld. Assuming you don't also need X11 forwarding, you can put

[time]

in ~/.wsld.toml, and follow the instructions there to setup automatic startup.

It will sync time from Windows every 10 minutes, and will adjust time like NTP.

@yanrez
Copy link
Member

yanrez commented Mar 30, 2021

This is dup of #5324

@therealkenc
Copy link
Collaborator

/dupe #5324

@ghost
Copy link

ghost commented Mar 31, 2021

Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.

Thanks for your report!

@ghost ghost closed this as completed Mar 31, 2021
@ghost ghost added the duplicate label Mar 31, 2021
@nbdd0121
Copy link

I don't think this is a dupe; I've seen my clock drifting without sleep or hibernation.

@jordansissel
Copy link
Author

jordansissel commented Mar 31, 2021 via email

@Animeshz
Copy link

Animeshz commented May 7, 2021

Since this issue pops first from google, Issue comment 5650 here's how one can install the update 😁, this has fixed the issue for me 😄

@scottshambaugh
Copy link

scottshambaugh commented Nov 21, 2022

I ran into this today,
ERROR: Clock skew detected. File /mnt/c/Users/Scott/Documents/Documents/Coding/scipy/build/meson-private/coredata.dat has a time stamp 42373.3841s in the future.
and the sudo hwclock -s command fixed it. Might have had something to do with not restarting since the daylight savings time switch?

@edmoman
Copy link

edmoman commented Feb 6, 2023

I keep receiving the message even after trying the hwclock and touch workarounds.

The problem seems to be that the files generated during compiling have a timestamp 2-4 second in the future.

This seems as a major bug to me.

Keep in mind that most companies block the Microsoft Store and implement proxies that block NTP.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate needs-investigation likely actionable and/or needs more investigation
Projects
None yet
Development

No branches or pull requests