Linux Security shutdown scripts

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.