how to sync windows time from a ntp time server in command
Asked Answered
S

4

36

I am working on windows 7. I can sync time of win7 from a ntp linux server manually. How can I do that in command prompt. So I can run it on windows startup. And windows task plan not work for me. The time should be like this:

Linux server -->  windows 7.

Any one knows that? Thank you. I can read msdn.

Schmeltzer answered 4/4, 2014 at 12:0 Comment(0)
S
34

Use net time net time \\timesrv /set /yes

after your comment try this one in evelated prompt :

w32tm /config /update /manualpeerlist:yourtimerserver
Stores answered 4/4, 2014 at 12:12 Comment(10)
service not start @Kayasax I have run sc start w32time. Windows time service already started.Schmeltzer
It runs successfully without error. But time was not change. When I run time /t. It make me crazy. @KayasaxSchmeltzer
Is there exists a delay? @KayasaxSchmeltzer
It will not change other machine in local network and domain, right?Schmeltzer
nope, except if you do that on your domain time serverMending
My machine is client. Not domain server. and not time server.Schmeltzer
Oh my god. It changes now. Thank you.Schmeltzer
@Kayasax w32tm /resync says "The computer did not resync because the required time change was too big." as my CMOS battery is dead and my computer clock resets on every boot at 1/1/2000 12:00 AM. Any help?Corruptible
@Kayasax Found solution as per blog.bruteforcetech.com/archives/911 , do not forget to restart W32Time service net stop W32Time then retry w32tm /resyncCorruptible
Also if you are on a VM turn off the VMICTimeProvider with the following registry tweak! serverfault.com/a/490619/169771Ioved
M
65
net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"0.it.pool.ntp.org 1.it.pool.ntp.org 2.it.pool.ntp.org 3.it.pool.ntp.org"
net start w32time
w32tm /config /update
w32tm /resync /rediscover

.BAT Sample File: https://gist.github.com/thedom85/dbeb58627adfb3d5c3af

I also recommend this program: http://www.timesynctool.com/

Mosira answered 25/2, 2016 at 11:29 Comment(1)
Solved my problem thanks. I have a workstation that is domain joined so time settings "Are managed by your organisation" but is is being used away from the domain at the moment.Bumkin
S
34

Use net time net time \\timesrv /set /yes

after your comment try this one in evelated prompt :

w32tm /config /update /manualpeerlist:yourtimerserver
Stores answered 4/4, 2014 at 12:12 Comment(10)
service not start @Kayasax I have run sc start w32time. Windows time service already started.Schmeltzer
It runs successfully without error. But time was not change. When I run time /t. It make me crazy. @KayasaxSchmeltzer
Is there exists a delay? @KayasaxSchmeltzer
It will not change other machine in local network and domain, right?Schmeltzer
nope, except if you do that on your domain time serverMending
My machine is client. Not domain server. and not time server.Schmeltzer
Oh my god. It changes now. Thank you.Schmeltzer
@Kayasax w32tm /resync says "The computer did not resync because the required time change was too big." as my CMOS battery is dead and my computer clock resets on every boot at 1/1/2000 12:00 AM. Any help?Corruptible
@Kayasax Found solution as per blog.bruteforcetech.com/archives/911 , do not forget to restart W32Time service net stop W32Time then retry w32tm /resyncCorruptible
Also if you are on a VM turn off the VMICTimeProvider with the following registry tweak! serverfault.com/a/490619/169771Ioved
A
10

If you just need to resync windows time, open an elevated command prompt and type:

w32tm /resync

C:\WINDOWS\system32>w32tm /resync 
Sending resync command to local computer 
The command completed successfully.
Antineutrino answered 2/12, 2016 at 0:18 Comment(0)
A
10

While the w32tm /resync in theory does the job, it only does so under certain conditions. When "down to the millisecond" matters, however, I found that Windows wouldn't actually make the adjustment; as if "oh, I'm off by 2.5 seconds, close enough bro, nothing to see or do here".

In order to truly force the resync (Windows 7):

  1. Control Panel -> Date and Time
  2. "Change date and time..." (requires Admin privileges)
  3. Add or Subtract a few minutes (I used -5 minutes)
  4. Run "cmd.exe" as administrator
  5. w32tm /resync
  6. Visually check that the seconds in the "Date and Time" control panel are ticking at the same time as your authoritative clock(s). (I used watch -n 0.1 date on a Linux machine on the network that I had SSH'd over into)

--- Rapid Method ---

  1. Run "cmd.exe" as administrator
  2. net start w32time (Time Service must be running)
  3. time 8 (where 8 may be replaced by any 'hour' value, presumably 0-23)
  4. w32tm /resync
  5. Jump to 3, as needed.
Atkinson answered 3/6, 2018 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.