SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / server / Questions / 294787
Accepted
Kyle Brandt
Kyle Brandt
Asked: 2011-07-28 13:47:05 +0800 CST2011-07-28 13:47:05 +0800 CST 2011-07-28 13:47:05 +0800 CST

How do I force sync the time on Windows Workstation or Server?

  • 772

What is the command to sync a Windows workstation or server to its configured time source?

windows time
  • 13 13 Answers
  • 1024505 Views

13 Answers

  • Voted
  1. Best Answer
    Seanchán Torpéist
    2011-07-28T13:52:24+08:002011-07-28T13:52:24+08:00

    As Kyle said w32tm /resync is the modern way to do this. See this Link to Microsoft Knowledgebase (KB 307897) for more information on the w32tm command.

    There is also net time which is an older version but perhaps easier.

    • 113
  2. user3011708
    2015-07-28T23:27:15+08:002015-07-28T23:27:15+08:00

    For those that still asking this question.

    1. To update, use the command below (2008 and 2012 server compatible)

      w32tm /config /manualpeerlist:"ntp_server" /syncfromflags:manual /reliable:yes /update
      

    change the ntp_server with your source

    1. Restart the time service

      net stop w32time
      net start w32time
      
    2. Resync the time

      w32tm /resync
      
    3. Verify your sync status

      w32tm /query /status
      

    Commands above should be fine if your sources are working correctly and/or your connection is OK (firewall or Microsoft Forefront can be an issue also). The commands below can help with troubleshooting

    To list out peers

    w32tm /query /peers
    

    To list out NTP Sources:

    w32tm /query /source
    
    • 55
  3. Kyle Brandt
    2011-07-28T13:47:19+08:002011-07-28T13:47:19+08:00

    You can use the following command:

    w32tm /resync

    • 25
  4. Brett Larson
    2012-12-12T08:44:42+08:002012-12-12T08:44:42+08:00

    You can use:

    w32tm /resync
    

    Additionally, using w32tm /resync /rediscover will also "force redetection of network resourced before resynchronization."

    Or using:

    net time /set
    

    Will prompt you to set the time to the DC. (Works for older versions of Windows)

    • 21
  5. Akos
    2017-05-14T05:36:08+08:002017-05-14T05:36:08+08:00

    OS: MS Windows 7

    All above ideas have been tried but did not help. The original problem still exists: "The computer did not resync because the required time change was too big."

    Solution is found in the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config

    • change this if the local time is in a hurry (e.g. 31-Dec-2050): MaxNegPhaseCorrection
    • change this if the local time is delayed (e.g. 1-Jan-1980): MaxPosPhaseCorrection
    • The default values are 0xD2F0 (i.e. 54000 sec. = 15 hours)

    (use Google for more details)

    I use this simple win_clock_sync.bat file from Start Menu StartUp:

    echo off
    echo Sync computer time from internet
    echo.
    echo Back-up registry w32time\Config
    reg export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config exported_w32time.reg /y
    rem changing the registry keys temporarly:
    reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config /v MaxNegPhaseCorrection /d 0xFFFFFFFF /t REG_DWORD /f
    reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config /v MaxPosPhaseCorrection /d 0xFFFFFFFF /t REG_DWORD /f
    echo.
    echo w32tm /config /update
    w32tm /config /update
    echo.
    echo w32tm /resync /rediscover 
    w32tm /resync /rediscover 
    echo.
    echo Restore registry w32time\Config
    reg import exported_w32time.reg
    

    Enjoy! :-)

    • 5
  6. majkinetor
    2016-08-07T05:18:04+08:002016-08-07T05:18:04+08:00

    Powershell one liner if ntp server is configured:

    gsv w32time | sasv; w32tm /resync /force

    You can put this .bat file in the startup if you CMOS batery failed so it can resync upon OS start:

    @powershell -NoProfile -Command 'gsv w32time | sasv; w32tm /resync /force'
    
    • 4
  7. user5723841
    2021-06-15T18:34:22+08:002021-06-15T18:34:22+08:00
    • change your time server
    w32tm /config /manualpeerlist:"0.pool.ntp.org 1.pool.ntp.org" /syncfromflags:manual /update
    
    • fore update time
    w32tm /resync /force
    
    • 3
  8. Nato Boram
    2016-09-08T16:59:24+08:002016-09-08T16:59:24+08:00
    net start w32time
    w32tm /resync
    

    According to Riot Games

    • 1
  9. Dmytro Andronov
    2020-11-05T05:53:00+08:002020-11-05T05:53:00+08:00

    Based on my research, I bookmarked this:

    1. If Hyper-v host server is a part of the same domain, disable time sync for PDC guest vm

    2. On PDC(or any single workstation), update from quoted internal DNS or ip untrusted address(0x8):

      W32tm /config /manualpeerlist:"192.168.0.254,0x8" /syncfromflags:manual /reliable:yes /update

      Powershell Restart-Service w32time

      W32tm /resync /nowait

    3. on dc that is not PDC:

      w32tm /config /syncfromflags:domhier /update

      W32tm /resync /rediscover

    4. On servers and other stations for update time only, not config:

      W32tm /resync /nowait

    5. Check that time is really updating(difference ):

      w32tm /stripchart /computer:192.168.0.254 /samples:15 /dataonly

    6. if time service broken or failed and need reset:

      Powershell Stop-service w32time W32tm /unregister Timeout 30 W32tm /register Powershell Start-service w32time

    Note: NTP port is 123 UDP and should give the same output on any healthy computer

    Powershell Get-NetUDPEndpoint -LocalPort 123
    
    
    LocalAddress                             LocalPort
    ------------                             ---------
    ::                                       123
    0.0.0.0                                  123
    

    Other commands w32tm /query /status w32tm /query /peers w32tm /query /configuration

    Best practice from ms: Time Sync best practices

    • 1
  10. Ding-Yi Chen
    2019-07-19T23:36:42+08:002019-07-19T23:36:42+08:00

    Almost none of the solutions (except @Akos) work if the host is an Windows Server 2016 Active Directory Domain Controller (ADDC), as it treats itself as a "reliable" source that cannot make big time change.

    w32tm /resync /force does not work, because the /force does not appear in server 2016.

    net time /SET /Y does not work either, because it would have asked:

    Do you want to set the local computer's time to match the time at \AD.example.net? (Y/N) [Y]

    Of course, it won't work if you are on AD.example.net, /Y just hides the question.

    The steps work for me using PowerShell:

    1. Set w32time service as unreliable:
    w32tm /config /reliable:no /syncfromflags:manual /update
    

    Option /syncfromflags:manual means sync with NTP listed in peer list (i.e. external NTP), /update for notifying the time service the configuration have changed.

    1. Restart the w32time
    Stop-Service w32time
    Start-Service w32time
    
    1. Sync
    w32tm /resync
    

    This should work.

    1. If you DO need ADDC as a reliable time source, make it reliable again:
    w32tm /config /reliable:yes /update
    Stop-Service w32time
    Start-Service w32time
    
    • 0

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    Check if port is open or closed on a Linux server?

    • 7 Answers
  • Marko Smith

    How to automate SSH login with password?

    • 10 Answers
  • Marko Smith

    How do I tell Git for Windows where to find my private RSA key?

    • 30 Answers
  • Marko Smith

    What's the default superuser username/password for postgres after a new install?

    • 5 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Resolve host name from IP address

    • 8 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    Smudge Our security auditor is an idiot. How do I give him the information he wants? 2011-07-23 14:44:34 +0800 CST
  • Martin Hope
    kernel Can scp copy directories recursively? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh returns "Bad owner or permissions on ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil How to automate SSH login with password? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin How do I deal with a compromised server? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve