28

I have a few PCs that are losing time and I'd like Windows to sync them more often with the Internet time. I think the Windows default attempts to update only once per day, and does not update if the time server is not available (which seems to happen quite often) meaning the PCs can end up 20 or 30 seconds out.

I'd like to create a scheduled task to do this say every 5 minutes and if the default time server is not available use mul

I say Reinstate Monica
  • 25,487
  • 19
  • 95
  • 131
DermFrench
  • 627
  • 3
  • 9
  • 17
  • 2
    Wouldn't it be easier to determine the reason the computers in question cannot connect to the time server? – Ramhound Jan 07 '13 at 15:20
  • 2
    Have you looked at W32tm? http://technet.microsoft.com/en-us/library/cc773263(v=ws.10).aspx – Jane T Jan 07 '13 at 15:44
  • The default servers fail me often too. Try changing it into `pool.ntp.org` as suggested in this [answer](https://superuser.com/a/681610/177522) – jan-glx Apr 27 '17 at 20:09

5 Answers5

19

Folks, I got this running with windows built in w32tm and a scheduled task (see below).

First step was to config w32tm to use many different time servers (and also to log so we could see what was happening). Second step was to schedule w32tm in task scheduler. I liked this solutions as it didn't require any 3rd part tools. It is really important to set up the different time servers as I find quite often they don't respond.

Configure w32tm

Open Command prompt (Run the following as admin)

w32tm /config /manualpeerlist:"time.nist.gov time.windows.com time-nw.nist.gov time-a.nist.gov time-b.nist.gov time-a.timefreq.bldrdoc.gov time-b.timefreq.bldrdoc.gov time-c.timefreq.bldrdoc.gov utcnist.colorado.edu" /syncfromflags:manual /update

w32tm /query /configuration

Check to see the NTP server list is updated correctly ie it reflects the peer list you have just entered

w32tm /debug /enable /file:C:\windows\temp\w32time.log /size:10000000 /entries:300

Browse to directory and check to see the log has been created

Change system time manually(so that the time is now out of sync), then go back to command prompt and run the resync command

w32tm /resync

Check system time has been updated. **If you get an error about the time service not being started you can use the command net start w32time then try another resync

If you get the following error: The compter did not resync because the required time change was too big. then use this command to resync: w32tm /resync /force

If this works successfully then all you have to do is configure the following scheduled task to run as often as you want (it will use your peer list configured above).

Schedule w32tm

Program/Script Argument

%windir%\system32\sc.exe start w32time task_started
%windir%\system32\w32tm.exe /resync
moo
  • 1,560
  • 11
  • 11
DermFrench
  • 627
  • 3
  • 9
  • 17
  • 1
    By default, Windows Time gets updated time [at least every 9.1 hours](http://solutionslog.blogspot.com/2008/12/how-often-does-windows-ntp-correct.html). This is controlled by the `MaxPollInterval` registry entry discussed at that link. This entry's data is converted to seconds with the formula `2^Value`. e.g. If MaxPollInterval's value is `11`, then `2^11=2048sec=34minutes`. For those who want to reduce the update frequency *without* using a scheduled task, simply change this registry entry then restart the Windows Time Service with `net stop w32time` then `net start w32time`. – I say Reinstate Monica Apr 14 '17 at 21:35
  • 1
    "`/entries:300`" isn't the right option. It will only show entries logged with code #300, which isn't many entries at all. The idea is to use this parameter as a list of entry numbers to show, so "`/entries:0-300`" will show all of the possible events in the log. – MikeB Dec 11 '19 at 15:09
12

Go to Control Panel > Administrative Tools > Task scheduler

left is an folder tree, expand: Task scheduler library > Microsoft > Windows > Time synchonization

right click the task: SynchronizeTime > properties

On the tab: Triggers you can add the triggers you want.

Rudger
  • 239
  • 2
  • 4
  • The OP asked for a time sync interval of 20-30s. This is only possible with the trick to [define multiple triggers](http://stackoverflow.com/a/13740720/935614) – nixda May 17 '15 at 08:59
  • 2
    Common misconception, but you really can't be blamed! This scheduled task only ensures the Windows Time service is running... Thus, even if you trigger the task more often, it's still the service that decides when to synchronize, which apparently is weekly. – Gras Double Nov 14 '15 at 08:54
  • 9
    To change poll frequency: registry key `HKLM\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpClient`, edit DWORD `SpecialPollInterval`, in seconds (e.g. for one day: hexadecimal 15180 or decimal 86400). – Gras Double Nov 17 '15 at 16:12
  • Great! this trick worked for me on my W7 OS – razor7 Jun 15 '16 at 00:16
  • @GrasDouble Important note: `SpecialPollInterval` [only works](https://blogs.msdn.microsoft.com/w32time/2008/02/26/configuring-the-time-service-ntpserver-and-specialpollinterval/) if there is at least one time server specified with the `0x1` flag (e.g. with the command `w32tm /config /manualpeerlist:"0.pool.ntp.org,0x1`). See also [this](https://support.microsoft.com/en-us/help/2638243/when-specialpollinterval-is-used-as-a-polling-interval,-the-windows-time-service-does-not-correct-the-time-if-the-service-gets-into-spike-state) and search "Windows Time uses SpecialPollInterval" – I say Reinstate Monica Apr 14 '17 at 21:46
  • 4
    Thanks Microsoft for making a simple sounding task such as time synchronization SO DAMN COMPLICATED. The only sane solution is to silently run a third-party utility on a regular basis. – Gras Double Apr 14 '17 at 23:40
4

You can use TimeSync to automate time syncing.

  • upside: doesn't register a whole service like W32tm (which you have, when you use W32tm)

  • upside: its portable and can be run with /auto option from the startup folder

  • downside: third-party tool and not a build-in solution

    enter image description here

TimeSync gets the current time from a NIST server, and adjusts the PC clock if necessary. Accuracy is usually within a second. [...] TimeSync will try alternative servers, in case the time cannot be obtained from the preferred server.

Option /auto is provided to run TimeSync from the StartUp folder. In this mode the TimeSync window will not show if the clock offset is under a given minimum.


Of course you can still register the build-in solution W32tm with cmd.exe → W32tm /register and set up your scheduled task to call cmd.exe → W32tm /resync every 5 minutes.

nixda
  • 26,823
  • 17
  • 108
  • 156
3

You can also try this program: http://www.worldtimeserver.com/atomic-clock/ It allows you to change windows time service settings - the easy way.

Also forcing sync with it works, while the windows "update now" almost never works.

NickSoft
  • 236
  • 1
  • 9
0

I run this command on kiosks that I manage.

net start w32time 
w32tm /resync /force

to manually set the date time:

date 5/24/2017
time 18:37:00

to Set the time zone:

tzutil/s Pacific Standard Time