判断进程存在的脚本

来源:互联网 发布:p2p监控软件 哪个最好 编辑:程序博客网 时间:2024/05/17 01:16
#!/bin/bash


for i in `pgrep mysql`;do


        kill -0 $i
        if [ $? != "0"  ];then
                echo "mysql $i process no exit"
        else
                echo "mysql $i process exit"
        fi
done


if [ -z $1 ];then
        echo "Need put in program name"    
        exit 1
else


        for i in `pgrep $1`;do


                kill -0 $i
                if [ $? != "0"  ];then
                        echo "$1 $i process no exit"
                else
                        echo "$1 $i process exit"
                fi
        done


fi


if [ -d /proc/$1 ];then
        echo " process $1 exit"
        exit 0
else
        echo " process $1 no exit"
        exit 1
fi
0 0
原创粉丝点击