zoukankan      html  css  js  c++  java
  • win2003系统同步Linux ntp server批处理

    最后更新时间: 2018/12/15


    一般windows配置时间服务器,只需要在windows系统右下角,点时间,里面配置好对应NTP服务器地址就行,

    image

    至多再修改一下注册表

     HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient

    SpecialPollInterval 改为 43200

    确保43200即12小时同步一次,但有些系统由于曾经加入过域,或者通过组策略管理的方式修改过NTP服务器,需要再修改注册表

    HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftW32timeParameters

    中配置 NtpServer 。


    经过梳理后,可以用以下bat脚本统一调整Ntp server 地址为 10.101.70.10 (根据实际情况填写ntp服务器IP)。


    rem 设置本批处理文件命令文件所在的文件夹
    
    set path=%SystemRoot%;%SystemRoot%system32
    
    rem 修改注册表项
    reg add "HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftW32timeParameters" /v "NtpServer" /t REG_SZ /d "10.101.70.10" /f
     reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionDataTimeServers" /v "0" /t REG_SZ /d "10.101.70.10" /f
     reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW32TimeConfig" /v "AnnounceFlags" /t REG_DWORD /d "10" /f
     reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient" /v "SpecialPollTimeRemaining" /t REG_MULTI_SZ /d "10.101.70.10,0" /f
     reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient" /v "Enabled" /t REG_DWORD /d "0x00000001" /f
    
    rem 修改为12小时同步一次
    reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient" /v "SpecialPollInterval" /t REG_DWORD /d "43200" /f
    
    rem 修改为客户端模式后重新同步
    
    w32tm /config /manualpeerlist:10.101.70.10,0x8 /syncfromflags:MANUAL
    
    net stop w32time
    
    net start w32time
    
    w32tm /resync
    
    rem 将Windows Time服务设置成随系统自动启动
    
    sc config w32time start= auto
    
    rem 设置完成
    pause


  • 相关阅读:
    CA 证书和数字证书
    PHP获取不了内网IP?
    站点速度检测工具
    Mac地址
    交互机和路由器区别
    关于实体店收银系统和cookie实现登录状态
    Python3 的序列
    Python3 字符串格式化
    Python3 的元组
    Python3 的列表
  • 原文地址:https://www.cnblogs.com/bugbeta/p/10122818.html
Copyright © 2011-2022 走看看