首页 > Web开发 > 详细

shell习题第25题:判断是否开启web服务

时间:2019-06-08 23:08:56      阅读:107      评论:0      收藏:0      [点我收藏+]

【题目要求】

写一个脚本判断我的linux服务器是否开启web服务?监听80端口

【核心要点】

netstat -lntp | grep ‘80‘

【脚本】

#!/bin/bash
n=`netstat -lntp | grep :80 | wc -l`

if [ $n -eq 0 ]; then
    echo "It not listen port 80"
else
    ser=`netstat -lntp | grep :80  | awk -F / {print $NF}`
    echo "It is listening port 80, and the server is $ser"
fi

 

shell习题第25题:判断是否开启web服务

原文:https://www.cnblogs.com/dingzp/p/10992051.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!