判断进程是否存在,使用命令ps、grep、sed、linuxjishu/13830.html target=_blank class=infotextkey>awk。
代码chk_ps.sh:
#!/bin/bash pid=`ps aux|grep -v grep|grep -v "test.sh"|grep $1|sed -n '1P' | awk '{print $2}'` if [ -z $pid ];then echo "there isn't this process!" else echo $pid fi
CopyRight © 2010-2021 脚本学堂 Jb200.com , All Rights Reserved.