if test $( pgrep -f processname | wc -l ) -eq 0
then
then
else
fi
解释:
pgrep -f processname 返回名字为processname的进程ID,如果有N个processname的进程则会分N行显示N个进程的ID
wc -l 统计行数
pgrep -f processname | wc -l将会获得一个数字,如果获取到的是0就说明processname进程不存在