I have two NTP servers with different IPs.
I’m trying to make a bash script that synchronizes the system clock with “ntpdate” client.
If first NTP server doesn’t respond, my script should try to connect to second NTP server.
I tried to make a system variable called RESULT in this way:
RESULT = ntpdate 192.168.100.41
NTP synchronization works, but when I make an “echo $RESULT”, its value is always 0.
So my question is:
Is there a correct way to do this? How?
Just check execution status stored in
$?:Alternatively, ir you are on Debian, use ntpdate-debian and specify server list in /etc/default/ntpdate, e.g.: