Solved: Clock Time Loss Under Windows7 and Vista 2

Posted by JD 01/16/2010 at 09:41

How to solve this

There are many ways to solve this issue. This is just the one I used based on my experience and expertise. I didn’t use this complex solution initially, it was only after all other solutions attempted failed, badly. My Windows Vista and Win7 computers were losing 2 minutes a day. After the first attempt to correct it with daily time sync, is was still losing about a minute, which was impacting some scheduled events. 1 minute off matters when someone else sets the start and end schedule.

What you need

  1. Windows7 and/or Windows Vista Computer with an inaccurate clock
  2. Debian-based Linux distribution. Actually, any UNIX solution should work in a very similar fashion, but these instructions are for APT-based Linux.

Setup an NTP Server

sudo apt-get update
sudo apt-get install ntp

Edit the /etc/ntp.conf

Verify the lines below exist on the Linux server

  • server pool.ntp.org
  • server ntp.ubuntu.com
  • restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
  • broadcast 192.168.1.255

You should correct the IP address and netmask for your network. There is no NTP authentication with these settings. I didn’t see a way to use NTP Auth with Windows.

Restart the NTP server

sudo /etc/init.d/ntp restart

If you need more information on the settings, man ntp.conf should help. There are different versions of NTP and v4 is more secure than v3.

Windows7 Setup

  1. Under Win7, type Date into the search bar.
  2. Select the Date and Time program
    1. Select the Internet Time tab
    2. Change Settings
    3. Check Synchronize with an Internet time server checkbox
    4. Type in the IP address for your Linux server running NTP. Using the hostname may work, but it didn’t for me.
    5. Click Update now button.
    6. Click OK

By default, Windows updates the clock once a week. If your clock isn’t accurate, this obviously isn’t often enough.

  1. Run regedit
    1. Search for ntpclient under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpClient
    2. Set SpecialPollInterval to a value in seconds. 1 hour is 3600 in decimal.

If you are still using an internet time server and not running one internally, never set the SpecialPollInterval to be less than 1 day. You will be banned for abuse from the time server.

Why you should solve this

Maintaining sub-second clock accuracy on a computer is important for encryption and authentication. A clock that is off more than a few seconds is a security vulnerability, especially if you are on a network and access other computer systems using shared credentials.

Network Time Protocol, NTP, has been around and working almost since the beginning of the internet. I know that in 1993, my employer had 3 NTP servers synchronized with hardware atomic signals so time drift could be accurately determined. Every computer on that network needed extremely accurate time so troubleshooting of real-time flight control issues weren’t compounded. Further, we used kerberos for authentication, so accurate time was critical.

On Microsoft Windows Server networks, I’ve seen time drift almost 5 minutes off. I find it hard to believe that MS can’t create, deploy, run a time service that is sub-second accurate. This problem was solved years ago. The solution works.

In the Windows Date/Time management interface, there are multiple internet time servers to chose. pool.ntp.org is the best choice that I know. The other servers are all bogged with too many requests. This is especially true for time.windows.com, which should be avoided at all costs.

How do you know that your clock is accurate?

Well, you should find a known-good time source. Often that is your TV cable and local TV stations. Sometimes there is an AM radio news station with an hourly BEEEP. Finally, you can visit time.gov, set your timezone and be fairly certain the displayed time is within a few seconds accurate. Good enough?

Virtual Servers and Time

If you run virtual servers, you need to know that the hypervisor OS is responsible for maintaining the clock for all client operating systems. Running NTP in a virtual machine, whether is it VMware, VirtualBox, Xen, or any other solution is a bad idea. Only the host/hypervisor should maintain the system clock.

5/2015 update:
For KVM-based virtual machines, “this article:”https://docs.fedoraproject.org/en-US/Fedora/13/html/Virtualization_Guide/chap-Virtualization-KVM_guest_timing_management.html recommends the following be run as Administrator (or with elevated rights):

bcdedit /set {default} USEPLATFORMCLOCK on

Try just changing the settings in Windows First

Before you go to the effort to setup an internal network NTP server, try to fix the issue with just the Windows GUI and registry pollinterval hack. But don’t set the poll interval to be less than 1 day, unless you want to be banned.

I suspect you could run an NTP server under Windows

If your windows systems are having trouble keeping time, I doubt running an NTP server under windows will be useful, but it may work. I’ve seen settings for NTPServer in the registry for both Vista and Windows7. Good luck.

Net Time command

c:\ net time \\timesrv /set /yes

This command can be setup to run hourly or daily using the built-in Task Scheduler to have better control over your time synchronization. I found that doing the registry hack to force time synchronization to be quicker eventually failed. I needed a more reliable way to keep time synchronized.

  • The account used for this in task scheduler must use a local administrator account.
  • This works from Windows7 to a Linux NTP server.
  • I suspect it will work to any other Windows PC running on the network, but I don’t know this as fact.

This last method may not work. 12 hours later and it seems one of the systems using this last method is off by about 2 minutes. That’s completely unacceptable to me. I probably didn’t get the administrative permissions elevated correctly.

Force Windows to Use UTC

I cannot believe that this isn’t the standard. There are many, many, many reasons for all computers to maintain time in UTC, but MSFT hasn’t gotten the message, at least not for home systems. If your BIOS is set to UTC (and it should be) OR you are running inside a VM hosted on any Unix system, then you need to force Windows desktops to understand that the hardware clock (or what a guest OS thinks of as the HW clock), is set to UTC.

Steps

  • regedit
  • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
  • Create dword “RealTimeIsUniversal” set value = 1
  • Restart Windows PC

Of course, you could create a .reg file with the setting and apply it. That is much faster if there is more than 1 Windows machine involved.

Trackbacks

Use the following link to trackback from your own site:
https://blog.jdpfu.com/trackbacks?article_id=418

  1. p-g-c@supanet.com 02/23/2010 at 09:41

    I cannot say that I am sorry for you losing time on your computer (2-3 minutes or so) since my machine with a brand new board used to lose thirteen hours and random losses of several hours all of the time. I only knew of it updating online once in four weeks use but it lost its time once turned of and back on some time later.
    I had my motherboard exchanged for another but that was absolutely no better.
    I am interested to know just what make of board you are using or was useing when the problems occurred, my board was a Gigabyte AM2+ Nvidia 720 DDR2 ATX AL, as I write this article I await a replacement and I hope it will not be the same type/model of board but a different one altogether.
    Incidently I am running Windows 7 Home premium, on a brand new HDD with new RAM and a 550watt power supply.
    You are not alone!!!!!!

  2. JD 02/23/2010 at 15:09

    Mine was on a Dell 1535 laptop with a Core2Duo T8100 CPU. The problem happened with both Vista and Windows7 (both 32-bit and 64-bit versions) until I forced it to use a different system for time synchronization every 15 minutes. After that, it maintained time well enough, but only because it was never allowed to drift much.

    I run MSI, Gigabyte, and Intel motherboards and none of them have shown huge clock drift issues. The first thing to try for a solution is to change the CMOS battery.

    Other places on the internet have less difficult methods to get Vista/Win7 time sync to be more accurate – I tried them and they didn’t help. Since I’ve run NTP servers for business networks, that was my solution as shown in this article.