Batch script for NTP sync up is not working everytime

H

Hutashan Kuldeep

Hi All,

I have batch script which will update the registry for NTP client configuration.

Sometimes script works but most of the times it fails to sync the clock time with internet.We have stand alone servers which are not part of AD.

Please find the below script. Request your help.


@ECHO off

@if not "%ECHO%" == "" echo %ECHO%
setlocal
@ECHO =========================
@ECHO Stopping the windows time service
net stop w32time
@ECHO ======================================================================
@ECHO Set the NTP (Network Time Protocol) source for the time server
w32tm /config /syncfromflags:manual /manualpeerlist:"time.nist.gov,0x01 pool.ntp.org,0x02"
@ ECHO Set the NTP Client Configurations ...
@ ECHO Set CrossSiteSyncFlags : 2
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpClient" /v CrossSiteSyncFlags /t REG_DWORD /d 2 /f
@ ECHO Set ResolvePeerBackoffMinutes : 15
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpClient" /v ResolvePeerBackoffMinutes /t REG_DWORD /d 15 /f
@ ECHO Set ResolvePeerBackoffMaxTimes : 7
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpClient" /v ResolvePeerBackoffMaxTimes /t REG_DWORD /d 7 /f
@ ECHO Set SpecialPollInterval : 3600
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpClient" /v SpecialPollInterval /t REG_DWORD /d 3600 /f
@ ECHO Set EventLogFlags : 0
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpClient" /v EventLogFlags /t REG_DWORD /d 0 /f
@ECHO =============================================
@ECHO Starting the windows time service
net start w32time
@ECHO =============================================
@ECHO Executing time sync service to use the changes
w32tm /config /update
@ECHO =======================================================
@ECHO Reseting the server/work station time against the time server
w32tm /resync /rediscover
:END
if "x%NOPAUSE%" == "x" pause
:END_NO_PAUSE


Continue reading...
 

Similar threads

M
Replies
0
Views
64
Mai Thiên Kim Nguyễn
M
M
Replies
0
Views
65
Mai Thiên Kim Nguyễn
M
Back
Top Bottom