Linux下基于端口的服务检查脚本
- 2023-04-16 05:24:22
- 来源:网络
- 在手机上看
扫一扫立即进入手机端
#!/bin/bash
#program:Usingtostudythe[if...then...fi]program
#dsk2007/10/83:00
#content:Iwillusingthisprogramtoshowyousevices
#1.printtheprogram''sworkinyourscreen
echo “Now,the service of your Linux system will be detect!“
echo “The www,ftp,ssh,and sendmail pop3 will be detect!“
echo ““
#2.www
www=`netstat -ntlp | awk '{print $4}' | grep :80$`
if [ “$www“ != ““ ];
then
echo $www
echo “WWW is runing“
else
echo $www
echo “WWW is NOT runing“
killall -9 httpd
/usr/sbin/Apachectl start
#service httpd start
fi
#3.ftp
ftp=`netstat -an | grep LISTEN | grep :21`
if [ “$ftp“ != ““ ]; then
echo $ftp
echo “FTP is runing “
else
echo “FTP is not runing“
killall -9 vsftpd
#service vsftpd start
/etc/init.d/vsftpd start
fi
#4.ssh
ssh=`netstat -ntlp | awk '{print $4}' | grep :22$`
#ssh=`netstat -an | grep LISTEN | grep :22`
if [ “$ssh“ != ““ ]; then
echo $ssh
echo “SSH is running“
else
echo “SSH is not running“
fi
#5.sendmail pop3
smtp=`netstat -an | grep LISTEN | grep :25`
pop3=`netstat -an | grep LISTEN | grep :110`
if [ “$smtp“ != ““ ] && [ “$pop3“ != ““ ]; then
echo “Send mail is OK!“
elif [ “$smtp“ != ““ ] && [ “$pop3“ = ““ ]; then
echo “ Send mail have some problems of your pop3!“
elif [ “$smtp“ = ““ ] && [ “$pop3“ != ““ ]; then
echo “Send mail have so me problems of your smtp!“
else
echo “Send mail is NO Trunning!“
fi
相关资讯
更多-
LINUX与UNIX SHELL编程指南
中文|19.1M
-
检疫镇手机版
中文|72.5M
-
国人健康馆
中文|102.4M
-
来趣拼购物app
中文|26.2M
-
决战平安京海外加速服
中文|1.92G
-
射击骑士团h5手游
中文|3.4M
-
我的ABC软件工具箱xclwinkits
中文|167.0M