Two scripts to check Linux network status _linux Shell

Source: Internet
Author: User

First, through the timing of email to detect network connectivity

Copy Code code as follows:

#/bin/bash
echo "Daily Test mail" > State.txt
Mail-s Server_state Abc@jb51.net < State.txt
Rm-df./state.txt

~
Crontab-e
Add the following tasks
* * */root/checknkmail &
Time-Sharing and Lunar Week

Second, timed detection network status by e-mail

Checkserverstat Script content:

Copy Code code as follows:

#/bin/bash
echo "Hztelecomdns" > State.txt
Ping-c 5 202.101.172.35 >> state.txt
echo "
BJU ">> state.txt
Ping-c 5 10.x.x.x >> state.txt
echo "ADSL Gateway" >>state.txt
Ping-c 5 x.x.x.x >> state.txt
echo "Server_outside VPN" >>state.txt
Ping-c 5 192.168.2.100 >>state.txt
echo "Server_outside WAN" >> state.txt
Ping-c 5 x.x.x.x >> state.txt
echo "VPN in Company" >> State.txt
Ping-c 5 192.168.1.4 >>state.txt
echo "L2TP at AAA libweb" >>state.txt
Ping-c 5 x.x.x.x & >>state.txt
Mail-s server_state admin@abc.com <state.txt
Rm-df./state.txt

Additional tasks in crontab
Copy Code code as follows:

Corntab-e
* * */root/checkweatherstate &
* * */root/checkserverstate &
* * */root/checkserverstate &
* * */root/checkserverstate &

Related Article

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.