Linux security shutdown script determines the key purpose after 4 minutes of power failure: after the power is down, the server connects to the UPS, And the UPS can only support up to 5 minutes without power, so let's make a judgment here, if the power is down for 4 minutes, the mains will be shut down before it comes. The following two devices are two vrouters connected to mains supply. If the two devices fail to be pinged, the server script considers the mains supply to be interrupted and shut down after 4 minutes. If one of them is different, the power supply will not be shut down. If one of the vrouters is connected within four minutes, the system determines that the mains is restored and the shutdown command is canceled .? Dest1 = 10.0.0.11dest2 = 10.0.0.12 #! /Bin/bash PATH =/sbin:/bin:/usr/sbin:/usr/bindest1 = 10.0.0.11dest2 = 10.0.0.12count = 0 while :; do sleep 5 for I in $ dest1 $ dest2 do ping-c1-w1 $ I &>/dev/null | (count ++ )) done if [$ count-lt 2]; then shutdown-c unset _ shut count = 0 else ["$ _ shut" = true] | {shutdown-h + 4 & _ shut = ture} fidone