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.
asked Apr 4, 2014 at 12:00
Use net time
net time \\timesrv /set /yes
after your comment try this one in evelated prompt :
w32tm /config /update /manualpeerlist:yourtimerserver
answered Apr 4, 2014 at 12:12
Loïc MICHELLoïc MICHEL
25.1k9 gold badges75 silver badges104 bronze badges
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.
answered Dec 2, 2016 at 0:18
Pedro LobitoPedro Lobito
94.5k31 gold badges258 silver badges270 bronze badges
0
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):
- Control Panel -> Date and Time
- «Change date and time…» (requires Admin privileges)
- Add or Subtract a few minutes (I used -5 minutes)
- Run «cmd.exe» as administrator
w32tm /resync
- 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 —
- Run «cmd.exe» as administrator
net start w32time
(Time Service must be running)time 8
(where 8 may be replaced by any ‘hour’ value, presumably 0-23)w32tm /resync
- Jump to 3, as needed.
answered Jun 3, 2018 at 18:18
starlockestarlocke
3,4272 gold badges25 silver badges38 bronze badges
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.
asked Apr 4, 2014 at 12:00
Use net time
net time \\timesrv /set /yes
after your comment try this one in evelated prompt :
w32tm /config /update /manualpeerlist:yourtimerserver
answered Apr 4, 2014 at 12:12
Loïc MICHELLoïc MICHEL
25.1k9 gold badges75 silver badges104 bronze badges
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.
answered Dec 2, 2016 at 0:18
Pedro LobitoPedro Lobito
94.5k31 gold badges258 silver badges270 bronze badges
0
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):
- Control Panel -> Date and Time
- «Change date and time…» (requires Admin privileges)
- Add or Subtract a few minutes (I used -5 minutes)
- Run «cmd.exe» as administrator
w32tm /resync
- 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 —
- Run «cmd.exe» as administrator
net start w32time
(Time Service must be running)time 8
(where 8 may be replaced by any ‘hour’ value, presumably 0-23)w32tm /resync
- Jump to 3, as needed.
answered Jun 3, 2018 at 18:18
starlockestarlocke
3,4272 gold badges25 silver badges38 bronze badges
C:\> w32tm /stripchart /computer:foo
Tracking foo [1.2.3.4].
The current time is 19/07/2012 17:39:48 (local time).
17:39:48 d:-00.0000840s o:-25.3004160s [@ | ]
17:39:50 d:-00.0000680s o:-25.3070080s [@ | ]
17:39:52 d:-00.0000690s o:-25.2987405s [@ | ]
17:39:54 d:-00.0000680s o:-25.3071530s [@ | ]
17:39:56 d:-00.0000690s o:-25.2993985s [@ | ]
17:39:58 d:-00.0000680s o:-25.3070270s [@ | ]
Wireshark shows NTP packets being generated by this. Some versions of w32tm have a /query option
C:\>w32tm /stripchart /computer:us.pool.ntp.org /dataonly /samples:5
Tracking us.pool.ntp.org [208.87.221.228:123].
Collecting 5 samples.
The current time is 19/07/2012 18:36:32.
18:36:32, +03.3575094s
18:36:34, +03.3573679s
18:36:37, +03.3572986s
18:36:39, +03.3570290s
18:36:41, +03.3565357s
Ensuring your computer’s clock remains accurate might seem like a small detail, but it’s a critical component in maintaining the overall health and functionality of your system. This is especially true for businesses that rely on accurate timestamps for things like log files, data synchronization, and security protocols. In this guide, we’ll dig deeper into the steps of synchronizing your Windows 11 clock with an internet time server, changing your Network Time Protocol (NTP) server, and refreshing your NTP time using the command prompt (CMD).
Also see: How to Change Date and Time Format in Windows 11
The importance of accurate time in PC
Time synchronization is important not just about having the correct time displayed on your taskbar. Time synchronization is fundamental for various computer operations, ranging from file management and scheduling tasks to network authentication and logging activities. It ensures that all actions are coordinated and logged in the correct sequence, which is especially crucial in networked environments.
Windows 11, like its predecessors, utilizes the Network Time Protocol (NTP) to sync its internal system clock with external time servers. By default, Windows synchronizes with time.windows.com, but there are many other public NTP servers available.
Linked issue: Date and Time is Always Wrong in Windows
Synchronizing Windows 11 time with the internet using CMD
To ensure your system’s time is accurate, Windows 11 provides a feature that allows your system to synchronize its time with an internet time server. Here’s how you can activate this feature using CMD:
- Open the Command Prompt as an administrator. To do this, you can simply search for “cmd” or “command prompt” via the Start menu, right-click on “Command Prompt” in the search results, and choose “Run as administrator” from the context menu.
- Once the Command Prompt window is open, enter the following command:
w32tm /resync
- After typing the command, hit the Enter key. If the command has executed successfully, you should see a message stating that the command completed successfully. This process syncs your system’s clock with the default internet time server.
The time synchronization feature can also help you solve issues like slow or fast system clocks, ensuring your computer’s time is as accurate as possible.
Related resource: How to Change Date and Time Format in Windows 11
Changing NTP time server in Windows 11
By default, your Windows system synchronizes its clock with Microsoft’s time server. However, there might be situations where you want to synchronize with a different NTP server—for instance, when the default server is unreachable, or you want to use a local time server within your network. Here’s how you can change the NTP server using CMD:
- Open the Command Prompt as an administrator.
- In the Command Prompt window, type the following command to change the NTP server. Replace “time.nist.gov” with the address of your preferred NTP server:
w32tm /config /syncfromflags:manual /manualpeerlist:time.nist.gov
- After entering the command, hit the Enter key. This command changes your NTP server to the one you’ve specified.
- To make sure the changes are implemented, type the following command and hit Enter:
w32tm /config /update
- Following this, synchronize your system’s clock with the new NTP server using the w32tm /resync command.
Refreshing NTP time
Refreshing the NTP time in Windows is as simple as forcing a resync. Follow the steps under “Synchronizing Windows 11 Clock using CMD” and execute the “w32tm /resync” command line to perform this task whenever you feel the need to update or correct your system clock.
Troubleshooting time synchronization issues
Despite your best efforts, there might be times when the time synchronization process encounters problems. For instance, you might get an error message when trying to run the w32tm /resync command. Common errors include “The service has not been started (0x80070426)” or “The computer did not resync because the time service was shutting down.”
In such cases, you can use the following command to restart the w32time service which can often fix any issue related to time syncing in Windows 11 or 10:
net stop w32time
net start w32time
After the service has been restarted, you can attempt to resync the time using the w32tm /resync command.
If that doesn’t work to resolve your time synchronization issue, try to unregister and re-register the time service in Windows using the following commands:
w32tm /unregister
After running the above command, run the following command:
w32tm /register
After you have re-registered the service, you should restart the service.
If you encounter the error message “The specified service has been marked for deletion (0x80070430)” when running “w32tm /unregister” command, run the commands in the following order instead:
- First, unregister the Windows Time Service by entering the following command:
w32tm /unregister
. - Next, stop the Windows Time Service with this command:
net stop w32time
. - Afterward, re-register the Windows Time Service using this command:
w32tm /register
. - Lastly, start the Windows Time Service again with the command:
net start w32time
.
These commands will help you to unregister, stop, re-register, and restart the Windows Time Service, thereby resolving the issue.
Final thoughts
While it might seem like a minor detail, keeping your system’s clock accurate is critical for maintaining the functionality of your computer, especially if you are part of a larger network. Whether you’re troubleshooting a time-related issue or simply ensuring that your system’s clock is as accurate as possible, these commands provide you with the tools to manage your system’s time settings.
Moreover, using CMD over the graphical user interface (GUI) provides significant advantages. The command line allows for automation of these tasks, a vital feature for administrators managing multiple machines. Scripts with the necessary commands can be created and scheduled to run at specific intervals, ensuring time synchronization is always maintained. Additionally, CMD commands can be executed remotely, making it a more flexible option for networked environments.
Правильней использовать термин «Служба времени Windows» вместо NTP, но к сожалению из-за слишком долгой работы с разными юниксами мне очень сложно перестроиться. Надеюсь опытные пользователи Microsoft или MVP не будут писать гневные комментарии. MCSA или MCSE я думаю сюда и не заглянут — они и так всё знают 😎
Win+R → cmd → Enter
Формат команды для проверки доступности NTP сервера
w32tm /stripchart /computer:доменное.имя_ИЛИ_IP.NTP.сервера /dataonly /samples:5
Проверим сервер time.windows.com
w32tm /stripchart /computer:time.windows.com /dataonly /samples:5
Я могу ошибаться, но похоже Windows Server не разрешает устанавливать несколько NTP серверов через GUI.
К счастью я нашёл отличный .bat’ник на github
@echo on & @setlocal enableextensions @echo ========================= @echo Turn off the time service net stop w32time @echo ====================================================================== @echo Set the SNTP (Simple Network Time Protocol) source for the time server w32tm /config /syncfromflags:manual /manualpeerlist:"time.cloudflare.com time.google.com time.windows.com ntp.ripe.net" @echo ============================================= @echo ... and then turn on the time service back on net start w32time @echo ============================================= @echo Tell the time sync service to use the changes w32tm /config /update @echo ======================================================= @echo Reset the local computer's time against the time server w32tm /resync /rediscover @endlocal & @goto :EOF
Обычно я использую для синхронизации time.cloudflare.com time.google.com time.windows.com ntp.ripe.net
или ntp.ripe.net ntp.nic.cz ntp.time.nl time.google.com
.
Для наглядности я ввёл все команды из примера выше вручную
Теперь можно посмотреть список наших NTP серверов (/peers: отображение списка узлов и их состояние)
w32tm /query /peers
Посмотреть статус синхронизации с NTP (/status: отображение состояния службы времени Windows)
w32tm /query /status
Посмотреть конфигурацию NTP (/configuration: отображение конфигурации времени выполнения и места, где берется параметр).
w32tm /query /configuration
Ещё несколько полезных команд.
Выполнить синхронизацию
w32tm /resync
Показать текущий часовой пояс (time zone)
w32tm /tz
Вернуть всё в default
net stop w32time w32tm /unregister w32tm /register net start w32time
EOM
Сайт rtfm.wiki использует cookies и трекинг посещений. Продолжая использовать этот сайт, вы соглашаетесь с сохранением файлов cookie на вашем компьютере. Если вы не согласны покиньте сайт или включите Adblock 😎 Что такое cookies? 🍪