How do I synchronize clocks between Linux and Windows?
Make both machines be NTP clients. That should make their clocks correct to within a rather short interval, and is already developed, tested, and available.
According to the Wikipedia page on NTP, you should expect around 10 ms over Internet, far less if you have a local time server on your LAN, which should be quite easy to set up.
how to sync windows time from a ntp time server in command
Use net timenet time \\timesrv /set /yes
after your comment try this one in evelated prompt :
w32tm /config /update /manualpeerlist:yourtimerserver
How to sync time between windows and linux computers?
You can set up a NTP Server on one of the Linux machines and have the others point to it.
- How to setup a NTP-Server with Redhat
Connect to the NTP-Server in Redhat:
ntpdate -du ntpservername
Connect to the NTP-Server in Windows XP:
- Right click on the clock in the system tray
- Choose adjust time
- On the
internet time
tab insert your server hostname
WSL2 Clock is out of sync with Windows
UPDATE: as mentioned by drkvogel, the Clock Sync fix was released in WSL2 kernel version 5.10.16.3
OBSOLETE
At time of writing, this GitHub Issue was open for the bug.
The workaround I chose for my situation (single distro in WSL2) is to use Windows Task Scheduler to run hwclock
in WSL
whenever Windows resyncs hardware clock.
Windows: Open PowerShell as Administrator
schtasks /create /tn WSLClockSync /tr "wsl.exe sudo hwclock -s" /sc onevent /ec system /mo "*[System[Provider[@Name='Microsoft-Windows-Kernel-General'] and (EventID=1)]]"
Set-ScheduledTask WSLClockSync -Settings (New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries)
WSL2: Run
sudo visudo
and addhwclock
to sudoers to skip password prompt
# bottom of my file looks like this
...
...
#includedir /etc/sudoers.d
<username> ALL=(ALL) NOPASSWD:/usr/sbin/hwclock, /usr/bin/apt update, /usr/bin/apt upgrade
Results
See image for how to get Event XPath from Windows Event filtering. Use as provided to let task scheduler auto-display scheduled triggers.
Related Topics
How to Read Input from the Terminal Using /Dev/Stdin and Read.Csv()
Bash -Eq and ==, What's the Diff
Elegant Way to Set Base Address of Elf Image with Linux Binutils
Print the Output of Strace Command in a Text File
What Is the Aligment Requirements for Sys_Brk
Recursively Rename Files to Ascii Standard
Delete Folder That Contain Subfolders and Files on Linux
Undefined Reference to 'Pthread_Init' When Using -Lpthread Flag:
Serialport in Mono in Linux Not Responding to Datareceived Event
How to Identify the User Who Owns a Process from /Proc/Pid
Cuda 5.0: Replacement for Cutil.H
Python3 Unicodeencodeerror When Run via Synology Task Scheduler
Escaping Single Quotes in Shell for Postgresql
Unusual Behaviour of Linux's Sort Command
Why a Linux Redirect Truncates the File
Mongod Does Not Start (Mongod.Service: Failed with Result 'Signal')
How to Increase Openfabrics Memory Limit for Torque Jobs
After Segfault: Is There a Way, to Check If Pointer Is Still Valid