The other day I got a client asking for help syncing time across all Windows 10 thin clients with their NTP server. After taking a walk around NYC and witnessing many hanging shoes I refreshed my head I found a useful way to check Windows NTP configuration using the command prompt.
Using w32tm To Check and configure NTP using the Command Prompt
In Windows 10 open your command prompt and type the below command to check your current NTP configuration:
w32tm /query /configuration
The above gives you the current time configuration.
w32tm /query /status
The above shows you many more details, such as: stratum, precision, last sync, NTP server and etc..
time /T
This last one shows the current time.
At some Windows10 machines I got the below error:
The following error occurred: The service has not been started. (0x80070426)
This means the time service has is not running or disabled. I made sure to enabled accordingly either using the command prompt:
net start w32time
or at the services window when the above did not work:
There’s also a way to set and start Windows NTP configuration using the command prompt this way:
w32tm /config /manualpeerlist:10.0.0.5 /syncfromflags:manual /reliable:yes /update
Then, as usual Windows stays problematic. I had to run the below commands in sequence:
w32tm /unregister
w32tm /register
net start w32time
I did all these because I found out by running:
net time /querysntp
I got the deprecated error:
The /QUERYSNTP and /SETSNTP options have been deprecated. Please use w32tm.exe to configure the Windows Time Service.
At the end of the config you might need to run:
w32tm /config /update
w32tm /resync /rediscover
To make Windows 10 rediscover its NTP settings. Play around, research the official Windows documentation. You can also place all these command on a batch file and deploy it to all your clients.
Good luck! Contact me if you have any questions. Remember to check out my IT Handyman shop for cool T-Shirts and coffee mugs I designed once in a while.
Download Windows Speedup Tool to fix errors and make PC run faster
Internet Server Time is used to keep your system clock accurate and thus it is very important to keep your internet time updated. Your Windows PC uses the clock to update and modify your files. While the Date & Time settings for Windows are pretty easy to access, to access the Timer Server settings, one has to go through the control panel. In this post, we see how to change Time Server in Windows 11/10. We will also see how to add new Time Servers of your choice to your Windows 10 system.
Type “Control Panel” in Start search and hit Enter to open the Control Panel of your Windows 11/10 PC.
Type “Date and Time” in the search box and click on the result.
Click on the ‘Internet Time’ tab and hit on the ‘Change Settings’ button.
From the drop-down menu, select, say, time.nist.gov as the Server and hit the ‘Update now’ button.
If you receive any error, try using pool.ntp.org as your time server and then hit the Update Now button.
Make sure you select the checkbox saying, Synchronize with an internet time server.
Add new Time servers to Windows 11/10
If you want to add more time servers to the drop-down list, open Registry Editor and go to the below path-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers
This will show you the list of current servers available-time.windows.com
- time-nist.gov
- time-nw.nist.gov
- time-a.nist.gov
- time-b.nist.gov
If you wish to add Time Servers, you could use the following for instance, or any other one of your choice:
- pool.ntp.org
- isc.org
Just select the server you want to add, right-click anywhere on the right side and select New > String Value. Enter the next number and give the Time server’s address in the Value field.
Once done, go back to the Date and Time settings, select your server and click on Update Now button.
Force Windows to sync Time using CMD
You can also force Windows to sync Time using W32tm.exe. W32tm.exe is a command prompt line used to configure, monitor or troubleshoot the Windows Time Service in Windows 11/10.
To do this, open an elevated command prompt and type the following commands one after the other:
net stop w32time
w32tm /unregister
w32tm /register
net start w32time
w32tm /resync
Reboot your computer and see if it has helped.
Also read: Windows Clock Time is wrong.
Anand Khanse is the Admin of TheWindowsClub.com, a 10-year Microsoft MVP (2006-16) & a Windows Insider MVP (2016-2022). Please read the entire post & the comments first, create a System Restore Point before making any changes to your system & be careful about any 3rd-party offers while installing freeware.
Reader Interactions
- Настройка сервера NTP на ОС Windows 10
- Автоматическая настройка
- Настройка вручную
- Настройка синхронизации времени и часового пояса на сервере RLP
Настройка сервера NTP на ОС Windows 10
Для настройки сервера понадобятся права администратора у пользователя Windows.
Автоматическая настройка
- Скачайте файл NTP_server_setup.bat
- Нажмите на файл правой кнопкой мыши и в меню выберите Запуск от имени администратора. Если Windows запросит разрешения на внесение изменений приложением, нажмите кнопку Да.
- Подождите, пока скрипт настроит сервер NTP. Последняя команда скрипта выводит текущую конфигурацию службы времени. Если скрипт успешно настроил сервер NTP, то в разделе NtpServer опция Enabled будет выставлена в 1. Нажмите любую клавишу, чтобы завершить работу скрипта и закрыть окно командной строки.
Настройка вручную
- Зайдите в редактор реестра одним из способов:
- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите regedit и нажмите Enter.
- В строке поиска Windows наберите regedit и выберите найденное приложение Редактор реестра.
Если Windows запросит разрешения на внесение изменений приложением Редактор реестра, нажмите кнопку Да.
- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите regedit и нажмите Enter.
- В Редакторе реестра перейдите по пути
\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer
Для этого можно воспользоваться деревом в левой части окна или скопировать и добавить строку пути в поле в верхней части окна.
- Откройте окно изменения параметра Enabled двойным щелчком мыши по нему в правой части окна Редактора реестра. Измените значение параметра на 1 и нажмите кнопку ОК.
- В Редакторе реестра перейдите по пути
\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config
- Измените значение параметра AnnounceFlags на 5.
- Закройте Редактор реестра.
- Чтобы изменения вступили в силу, необходимо перезапустить службу времени Windows. Зайдите в управление службами одним из способов:
- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите services.msc и нажмите Enter.
- В строке поиска Windows наберите службы и выберите найденное приложение Службы.
- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите services.msc и нажмите Enter.
- В списке служб найдите Службу времени Windows.
- Дважды щёлкните на службу, чтобы зайти в окно её настройки.
Если служба в состоянии Остановлена, то нажмите кнопку Запустить и дождитесь запуска службы.
Если служба в состоянии Выполняется, сначала нажмите кнопку Остановить, дождитесь остановки службы, нажмите кнопку Запустить и дождитесь запуска службы.
Установите Тип запуска в Автоматически и нажмите кнопку ОК, чтобы сохранить настройку.
- Закройте окно Служб Windows.
- Для проверки, что сервер NTP запустился, можно использовать команду w32time командной строки Windows.
Запустите командную строку Windows одним из способов:- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите cmd и нажмите Enter.
- В строке поиска Windows наберите cmd и выберите найденное приложение Командная строка.
- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите cmd и нажмите Enter.
- В Командной строке наберите или скопируйте сочетанием клавиш Shift+Insert строку
w32tm /query /configuration
и нажмите клавишу Enter.
- Команда выведет текущую конфигурацию службы времени. Если сервер NTP запущен, то в разделе NtpServer опция Enabled будет выставлена в 1. Закройте окно Командной строки.
- Для работы сервера NTP нужно разрешить в Брандмауэре Windows UDP траффик по порту 123. Откройте Монитор брандмауэра Защитника Windows в режиме повышенной безопасности одним из способов:
- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите wf.msc и нажмите Enter.
- В строке поиска Windows наберите и выберите найденное приложение.
- Нажмите клавиши Win+R, в появившемся окне Выполнить наберите wf.msc и нажмите Enter.
- В окне Монитора брандмауэра… переключитесь на Правила для входящих подключений и нажмите на Создать правило…
- Выберите тип правила Для порта и нажмите кнопку Далее.
- Выберите Протокол UDP, впишите номер порта 123 и нажмите кнопку Далее.
- Выберите Разрешить подключение и нажмите кнопку Далее.
- Установите галочки для всех профилей и нажмите кнопку Далее.
- Введите имя правила, например, udp in 123 и нажмите кнопку Готово.
- Переключитесь на Правила для исходящего подключения и нажмите Создать правило. Создайте правило с такими же настройками (тип правила, протокол и порты и т.д.), как и в предыдущих пунктах.
- Закройте окно Монитора брандмауэра…
Настройка синхронизации времени и часового пояса на сервере RLP
Для копирования файлов по сети из ОС Windows можно использовать WinSCP.
Команды можно вводить как локально на сервере, так и удалённо по SSH. Для удалённого подключения можно использовать PuTTY.
Данные для подключения по умолчанию:
Логин: root
Пароль: root (при наборе пароля он может не отображаться, даже символами «звёздочка»)
- Скачайте и разархивируйте ntp_local_install.zip
- Скопируйте получившуюся папку
ntp_local_install
в папкуhome
на сервере RLP. - Зайдите на сервер локально или удалённо.
- Остановите службу TRASSIR командой:
systemctl stop t1daemon
- Установите rpm из скопированной папки командой:
yum install -y /home/ntp_local_install/*.rpm
- Зайдите в редактирование файла настроек планировщика задач командой:
crontab -e
- Нажмите клавишу Insert для перехода в режим редактирования.
Добавьте строку*/5 * * * * sudo ntpdate IP-адрес компьютера на Windows с настроенным NTP-сервером
Пример:*/5 * * * * sudo ntpdate 192.168.1.1
- Нажмите клавишу Esc, чтобы выйти из режима редактирования. Введите
:wq!
и нажмите клавишу Enter, чтобы сохранить изменения и выйти из редактора. - Проверьте текущий часовой пояс на сервере RLP командой
timedatectl status
Часовой пояс и город указаны в разделе Time zone:
- Если часовой пояс на сервере не совпадает с часовым поясом, где физически размещён сервер, то его можно поменять:
- Выведите список городов, поддерживаемых службой времени и выберите ближайший:
Для списка городов Европы введите команду:timedatectl list-timezones | grep Europe
Для списка городов Азии введите команду:timedatectl list-timezones | grep Asia
-
Установите нужный часовой пояс командой:
timedatectl set-timezone выбранный город
Пример:timedatectl set-timezone Asia/Vladivostok
Город нужно указать в том же виде, в котором он выводится командой
timedatectl list-timezones
, включая регистр букв. Если указать город неправильно, часовой пояс не изменится.
- Выведите список городов, поддерживаемых службой времени и выберите ближайший:
- Проверьте текущее время на сервере RLP командой:
date
Время должно совпадать со временем на компьютере с настроенным NTP-сервером. Если время не совпадает, то подождите пять минут (настроенный период синхронизации) и введите команду ещё раз.
Запустите TRASSIR командой:systemctl start t1daemon
удобный скрипт для работы со временем на серверах NTP доступен по ссылке:
https://ncloud.dssl.ru/s/HpQrdWMBLet7Wps
Skip to content
Every desktop computer keeps the correct time even when it is turned off by using a simple 3V Lithium battery cell (CR2032). But this is not a rechargeable battery cell, so it stops working after a year or so. You can easily replace this cell, but after replacing the cell, you have to update the time using the NTP servers so that your Windows PC keeps the accurate time. You can update the time using Windows graphical user interface and also through a command line interface (CLI). The CLI method works even when the time service is not properly configured in Windows.
Here is how you can sync time with NTP servers in Windows using the command line interface:
- Open an elevated command prompt. In Windows 8 and later versions, you can press the hotkey Win+X and choose Command Prompt (Admin) from the menu that shoes up. For earlier versions of Windows, you can search our side about opening elevated command prompt in Windows.
- In the elevated command prompt window, type the following commands. At the end of each line, press Enter to issue that command:
w32tm /register
sc start W32Time
w32tm /config /update /manualpeerlist:”pool.ntp.org” - These commands will register Windows Time service if it is not registered for some reason, start this service, change the time server to “pool.ntp.org” and finally sync the computer time with the NTP server. Obviously, instead of “pool.ntp.org”, you can change the time server to any time server of your choice.>
You can also download update-time-windows.zip, extract the contents to Windows desktop, right-click on update-time-windows.cmd and choose Run as administrator. This will automatically run a batch file containing all the necessary commands for syncing the time.
Conclusion: Using command line interface or a batch file to sync the Windows PC time with a remote NTP server can be useful when you have to update it frequently. The reasons for frequent syncing could be a failing battery or dual boot operating systems having different time zones set.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.