易网时代-编程资源站
Welcome
微信登录
首页
/
操作系统
/
Linux
/
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
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图