#!/bin/bash#by LCMAIL1=zongjian@lc.comMAIL2=jingli@lc.comMAIL3=lc@lc.comTOMCAT_PROT (){if [ `netstat -lntup|grep java |wc -l` -ne 3 ]then clear echo -e "\033[31m###########################\033[0m" echo -e "\033[31m\033[0m""\033[1;5;31m TOMCAT PROT CANT FIND \033[0m""\033[31m \033[0m" echo -e "\033[31m###########################\033[0m" echo "`date +%F_%H-%M-%S`WAP TOMCAT PROT CANT FIND"|mail -s tomcat $MAIL1 echo "`date +%F_%H-%M-%S`WAP TOMCAT PROT CANT FIND"|mail -s tomcat $MAIL2 echo "`date +%F_%H-%M-%S`WAP TOMCAT PROT CANT FIND"|mail -s tomcat $MAIL3 echo "===`date +%F_%H-%M-%S`===" >>/home/lichuang/tomcat_notok.txt netstat -lntup|grep java >>/home/lichuang/tomcat_notok.txtelse sleep 120 TOMCAT_PROTfi}main (){ TOMCAT_PROT}main
注:1)判断的端口数不要做成变量,有坑!!!
2)注意TOMCAT_PROT的位置