shell:判断一个进程是否存在 #test.sh #!/bin/sh pid=`ps -ef | grep -v grep | grep -v "test.sh" | grep $1 | sed -n '1P' | awk '{print $2}'` if [ -z $pid ] ; then echo "no this process" else echo $pid fi 例:查询是否存在hello进程#./test.sh hello如果存在hello进程,会输出PID不存在会输出 no this process 版权声明:本文为exbob原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。原文链接:https://blog.csdn.net/exbob/article/details/6223239