SoFunction
Updated on 2025-03-09

Shell implements the sharing of system time and BIOS time synchronization calibration scripts


#!/bin/bash
# NTP network time correction script
# Run

#NTP server array list
ntpServer=(

[0]=
[1]=
[2]=210.72.145.44
[3]=133.100.11.8
[4]=
[5]=

)

#check#
serverNum=`echo ${#ntpServer[*]}`
NUM=0
for (( i=0; i<=$serverNum; i++ )); do
  
echo -n "Checking with NTP server ${ntpServer[$NUM]}..."
    /usr/sbin/ntpdate ${ntpServer[$NUM]} >> /dev/null 2>&1
    if [ $? -eq 0 ]; then
echo -e "\e[1;32m\t\t\t\t\t[success]\e[0m"
        break
    else
echo -e "\e[1;31m\t\t\t\t\t\t[failed]\e[0m"
        let NUM++
    fi
    sleep 2

done

#Set the BIOS time and system time consistent
hwclock --systohc