Debian, Linux, Ubuntu, Windows, Windows 10, Windows 7, Windows 8, Windows Server, Windows Vista, Windows XP
- 08.06.2020
- 132 686
- 2
- 23.06.2021
- 47
- 46
- 1
- Содержание статьи
- Windows
- Linux
- Комментарии к статье ( 2 шт )
- Добавить комментарий
Если Вам потребовалось проверить, работает ли NTP сервер по определенному адресу в сети, то Вы можете легко это проверить через командную строку Windows, или терминал в Linux.
Windows
В Windows, нужно открыть командную строку и выполнить команду w32tm со специальными параметрами.
w32tm /stripchart /computer:[ИМЯ ИЛИ IP АДРЕС] /dataonly /samples:3
Например, для сервера clock.isc.org нужно написать вот так:
w32tm /stripchart /computer:clock.isc.org /dataonly /samples:3
Ответ будет содержать локальное время, и разницу со временем на указанном NTP сервере. Например:
C:\Users\Recluse>w32tm /stripchart /computer:clock.isc.org /dataonly /samples:3
Отслеживание clock.isc.org [64.62.194.189:123].
Сбор образцов 3.
Текущее время — 07.06.2020 19:55:28.
19:55:28, +00.0777312s
19:55:30, +00.0786069s
19:55:32, +00.0779390s
Linux
В Linux для проверки NTP сервера можно использовать утилиту ntpdate.
ntpdate -q [ИМЯ ИЛИ IP АДРЕС]
Для проверки сервера clock.isc.org команда приобретает следующий вид:
recluse@sysadmin.ru:~$ ntpdate -q clock.isc.org
Выглядеть её выполнение будет следующим образом:
recluse@sysadmin.ru:~$ ntpdate -q clock.isc.org
server 204.93.207.11, stratum 3, offset 0.005347, delay 0.15712
server 64.62.194.188, stratum 3, offset 0.003708, delay 0.20419
server 64.62.194.189, stratum 3, offset 0.002025, delay 0.19640
7 Jun 19:59:00 ntpdate[74019]: adjust time server 204.93.207.11 offset 0.005347 sec
I tried:
w32tm /query /status
I got:
The command /query is unknown.
In a different machine, I got:
The following error occurred: The service has not been started. (0x80070426)
Then I tried:
reg QUERY [\\machine\]HKLM\SYSTEM\CurrentControlSet\Services\W32Time
I got:
ERROR: The system was unable to find the specified registry key or value.
Then I tried:
net time /querysntp
I got:
This computer is not currently configured to use a specific SNTP server.
In another machine, I got the help page, saying also:
The /QUERYSNTP and /SETSNTP options have been deprecated. Please use w32tm.exe to configure the Windows Time Service.
So, basically, the service was not running. Following these instructions, I did:
w32tm /unregister
w32tm /unregister
w32tm /register
net start w32time
Finally, all the above would work. (note: if net start
fails, see below) Then I just needed to set my ntp up…
I did it with:
w32tm /config /manualpeerlist:10.0.0.5 /syncfromflags:manual /reliable:yes /update
following instructions from here, but perhaps it could’ve been as easy as:
net time /setsntp:10.0.0.5
as instructed here. (10.0.0.5 being my local NTP server). If you’re not using a local NTP server, you can use the generic one:
w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:manual /reliable:yes /update
Finally, you might need to do the following, which was not necessary for me:
w32tm /config /update
w32tm /resync /rediscover
NOTE: if net start w32time
fails with error 1290 (The service start failed since one or more services in the same process have an incompatible service SID type setting) then follow the steps here:
w32tm /unregister
w32tm /register
sc config w32time type= own
net start w32time
Then follow as above.
NOTE 2: if the NTP service doesn’t automatically start on reboot, it might be due to its start settings, as described here: depending on your windows, it might be set to start only when it joins a domain. You can check with:
sc qtriggerinfo w32time
If it’s configured to start when you join a domain, and you don’t have a domain set up in your machine, it will not start the service and set the time. It probably doesn’t join a domain because you don’t want it to. In any case, just change which trigger starts it. For example, to start when the machine has network (and therefore is able to access the server), do:
sc triggerinfo w32time start/networkon stop/networkoff
microsoft-windows:win-command-line-tools:w32tm-manage-windows-time-service
Содержание
Утилита w32tm — Управляем службой времени в Windows
Как настроить NTP-сервер с помощью w32tm?
Как проверить статус синхронизации с NTP-сервером с помощью w32tm?
Проверяем текущее состояние службы времени и статус последней успешной синхронизации с NTP-сервером:
w32tm /query /Status
Индикатор помех: 0(предупреждений нет) Страта: 4 (вторичная ссылка - синхронизирована с помощью (S)NTP) Точность: -6 (15.625ms за такт времени) Задержка корня: 0.0937500s Дисперсия корня: 7.9058435s Идентификатор опорного времени: 0x0AA01008 (IP-адрес источника: 10.10.1.8) Время последней успешной синхронизации: 14.07.2020 14:53:05 Источник: DC01.ad.holding.com Интервал опроса: 10 (1024s)
Как проверить доступность NTP-сервера с помощью w32tm?
Отсылается 5 запросов на UDP порт 123 NTP-сервера следующим образом:
w32tm /stripchart /computer:DC01.ad.holding.com /dataonly /samples:5
Ответ от NTP-сервера получим примерно такой:
Отслеживание DC01.ad.holding.com [10.10.1.8:123].
Сбор образцов 5.
Текущее время - 21.12.2016 10:28:13.
10:28:13, +00.1740513s
10:28:15, +00.1764264s
10:28:17, +00.1788762s
10:28:19, +00.1871543s
10:28:21, +00.1868310s
· Последнее изменение: 14.07.2020 15:09 —
Алексей Максимов
Правильней использовать термин «Служба времени 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? 🍪
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.