NTP-based multi-server time synchronization script
The server updates the time every hour. The synchronization server of the server synchronizes the time every five seconds. The synchronization server does not interact with the Internet, and the synchronization time is performed by the server. Therefore, ensure that the time of each synchronization server is consistent.
# Vi ud_ntp.sh
#! /Bin/bash
Time = 5
Ip (){
Echo "192.168.48.114"
Echo "192.168.28.233"
}
Stp (){
/Etc/init. d/ntpd stop
}
Upd (){
Ntpdate us.pool.ntp.org
}
Stt (){
/Etc/init. d/ntpd start
}
Num = 'ps-ef | grep ntpd. pid | grep-v grep'
Not (){
If [! -N "$ num"]; then
# Echo "is null"
Upd
Stt
Else
# Echo "not null"
Stp
Upd
Stt
Fi
}
Ntp (){
While true
Do
Sleep $ time
For I in 'IP'
Do
Ssh $ I ntpdate 192.168.48.117
If [[00 = 'date | awk-F ":" '{print $2} '']
Then
Not
Sleep 240
Break
Fi
Done
Done
}
Ntp &
What else do you think about!
CentOS NTP server installation and configuration
NTP servers in Linux
NTP client configurations for multiple operating systems
Build an enterprise-level NTP Time Server
Set up an ntp time synchronization server in Linux
Enable NTP time server in CentOS 6.3
This article permanently updates the link address: