2018/02/06

February 06 2018 Tuesday

Weather:clear
一、需求:
写一个脚本判断你的Linux服务器里是否开启web服务?(监听80端口)若是开启了,请判断出跑的是什么服务,是httpd呢仍是nginx又或者是其余的什么?nginx

#!/bin/bash
 port=`netstat -lnp | grep 80`
 if [ -z "port" ]; then
     echo "not start service.";
     exit;
 fi
 web_server=`echo $port | awk -F'/' '{print $2}'|awk -F : '{print $1}'` 
case $web_server in
   httpd ) 
       echo "apache server."
   ;;
   nginx )
       echo "nginx server."
   ;;
   * )
       echo "other server."
   ;; 
esac
本站公众号
   欢迎关注本站公众号,获取更多信息