windows icon indicating copy to clipboard operation
windows copied to clipboard

QEMU time

Open baiomys opened this issue 1 year ago • 15 comments

Is your question not already answered in the FAQ?

  • [X] I made sure the question is not listed in the FAQ.

Is this a general question and not a technical issue?

  • [X] I am sure my question is not about a technical issue.

Question

Windows time is out of sync without ARGUMENTS: "-rtc base=localtime" Should be handy to create dedicated ENVIRONMENT option for this if not created already.

baiomys avatar May 07 '24 09:05 baiomys

I will add this option by default in the next version so that you dont need to manually specify it.

kroese avatar May 07 '24 09:05 kroese

This is now fixed in v3.05.

kroese avatar May 12 '24 12:05 kroese

I have same issue, time difference between my debian 12 host and windows container is 2 hours.

dockurr/windows latest d380ee3be346 7 hours ago 371MB The image I am currently using, it happened on previous versions too.

@kroese

the4anoni avatar Jun 14 '24 09:06 the4anoni

I added this parameter "-rtc base=localtime" @baiomys suggested. So I dont know what more can I do.

Are you sure you set the correct timezone setting? Because that can also cause a difference.

kroese avatar Jun 14 '24 09:06 kroese

I added this parameter "-rtc base=localtime" @baiomys suggested. So I dont know what more can I do.

Are you sure you set the correct timezone setting? Because that can also cause a difference.

I did set correct timezone. After I do NTP sync in Windows time is ok, but is goes back after Windows reboot.

the4anoni avatar Jun 14 '24 09:06 the4anoni

@baiomys Do you have any idea?

kroese avatar Jun 14 '24 09:06 kroese

@baiomys Do you have any idea?

Maybe that fix just needs to be reverted or changed to something else?

https://docs.getutm.app/settings-qemu/qemu/

Use local time for base clock

This specifies the -rtc base=localtime option in QEMU. This synchronizes the guest clock to the local clock without any offsets. On some Linux guests, the RTC base is expected to be UTC and so this option should be disabled.

the4anoni avatar Jun 14 '24 09:06 the4anoni

"-rtc base=utc" in ARGUMENTS should help 95% guests run local time, so turning this option ON by default was reasonable

baiomys avatar Jun 14 '24 11:06 baiomys

My host is running Linux Mint 21.3 and I have added the ARGUMENTS: "-rtc base=localtime" statement to my existing compose file and restarted the container. But the Windows 11 time still shows a +5 hour difference from my local time which is Central Daylight Time. I did a test spinning up a new container with the above arguments line and after a new download and setup, the time on the Win11 container showed the correct local time after changing the time zone in the Windows time/date settings. I then shut down the container and started it up again keeping the ARGUMENTS statement intact. After startup, the time was not correct showing the same +5 hour time difference.

Is there any way to make the ARGUMENTS statement to take effect and persist on an existing container or after restart of the container.

Thanks

taylormia avatar Jun 22 '24 01:06 taylormia

"-rtc base=localtime" is set by default since version v3.05, did you try "-rtc base=utc"?
Anyway, after changing this option you need to manually RESYNC TIME in windows at least once to make it persistent.

baiomys avatar Jun 22 '24 02:06 baiomys

I have resynced the time in the Win11 container and restarted it with no change using "rtc base=localtime" I have also tried "rtc base=utc" and resynced the Win11 time and restarted with no change.

taylormia avatar Jun 22 '24 03:06 taylormia

Still does not work - but I have implemented a workaround by invoking a batch file at windows startup to sync time with NTP to get my correct local time.

taylormia avatar Jun 22 '24 20:06 taylormia

Still does not work - but I have implemented a workaround by invoking a batch file at windows startup to sync time with NTP to get my correct local time.

can you share that script here?

the4anoni avatar Jun 26 '24 15:06 the4anoni

@the4anoni Sure. Here's the content of the batch file:

@echo off
SC start "W32Time" & W32tm /ReSync

The batch file is placed in this directory: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

taylormia avatar Jun 26 '24 15:06 taylormia

@taylormia Thanks for the idea. I was also having this issue. So I created a Windows scheduled task with the highest level of privileges that gets triggered when any user logs in, and it runs: W32tm /resync /force

geckolinux avatar Jul 07 '24 01:07 geckolinux

heres how I addressed the incorrect timezone issue just prior to the Dockur/Windows container install. This was done in a build script but the same style of tweaks could be applied after install:

# Set the Windows time zone
	echo -e "\\n    [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation]\n    \"TimeZoneKeyName\"=\"Add_timezone_here\"" >> oem/RDPApps.reg"

# Enable the Windows timezone to update automatically
	 sed -i '$a\\n    [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\tzautoupdate]\n    "Start"=dword:00000003' oem/RDPApps.reg >/dev/null

# Build a script to sync the time at each startup
	# see issue https://github.com/dockur/windows/issues/465
        {
        echo 'echo @echo off > "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\timesync.bat"'
        echo 'echo SC start "W32Time" ^& W32tm /ReSync /force >> "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\timesync.bat"'
        echo 'SC start "W32Time" & W32tm /ReSync /force'
        } >> oem/install.bat

itiligent avatar Aug 24 '24 15:08 itiligent