自己常用的一些shell脚本分享

2019-09-23 09:36:07刘景俊

        echo "the user is :"
        who
        echo

        echo "this is `uname -s`"
        echo

        echo "that's all folks! "

25.检查端口号是否已启动

#!/bin/bash
n=1
echo "检查xxx服务..."
while true
do
        if test $n -gt 20
        then
                echo "xxx服务启动失败"
                break
        fi
               
        sleep 5
        n=$(($n+1))
        port=`netstat -antp | grep "0.0.0.0:8080"`
        if [ ${#port} -gt 3 ]; then
                echo "xxx服务已经启动"
                break;
        fi
done