博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux下基于端口的服务检查脚本
阅读量:6412 次
发布时间:2019-06-23

本文共 1357 字,大约阅读时间需要 4 分钟。

#!/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

转载于:https://blog.51cto.com/yanny/2091683

你可能感兴趣的文章
技术成长之路(一)
查看>>
中国北方国际五金城硬件选型
查看>>
php.exe启动时提示缺少MVCR110.dall 64位 window系统 解决
查看>>
判断是否为数字方法
查看>>
[翻译] EF Core in Action 关于这本书
查看>>
js Uncaught TypeError: undefined is not a function
查看>>
数据库存储引擎
查看>>
[2019.2.13]BZOJ4318 OSU!
查看>>
版本号带两个小数点的,如何比较大小?( NSStringCompareOptions )
查看>>
QCustomplot使用分享(三) 图
查看>>
什么是java?
查看>>
WPF路径动画(动态逆向动画)
查看>>
Low Level Reader Protocol (LLRP) 简介
查看>>
[Micropython]TPYBoard v10x NRF24L01无线通讯模块使用教程
查看>>
mysql中show processlist过滤和杀死线程
查看>>
最新Sublime Text 2 激活 汉化
查看>>
基础数据类型之字典
查看>>
第七次作业
查看>>
Oracle中NVARCHAR2与VARCHAR2的区别
查看>>
php debug
查看>>