Linux Security shutdown scripts
Judge the key after 4 minutes of power failure
Purpose: After the power outage server connection ups,ups can only support 5 minutes will not power, so make a judgment here, if the power outage 4 minutes later, the electricity has not come on the shutdown.
The following two devices are two under the router, connected to the mains, if the power outage two will not ping, the server script that the mains outage, 4 minutes after the shutdown, if there is a difference in the view that power failure is not shutdown. If within 4 minutes there is a router to pass, judging for the mains recovery, cancel the shutdown command.
? dest1=10.0.0.11
dest2=10.0.0.12
#!/bin/bash
Path=/sbin:/bin:/usr/sbin:/usr/bin
dest1=10.0.0.11
dest2=10.0.0.12
Count=0
While
: ; Do
Sleep 5
For i in $dest 1 $dest 2
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
}
Fi
Done
- This article is from: Linux Learning Network
Linux Security shutdown scripts