杀死进程循环检查

循环杀死进程命令,有的时候进程杀不死,但是后续命令需要依赖进程杀死后的结果。

cnt=1;while (($cnt > 0)) ;do `ps -ef | grep test.py | grep -v grep | awk '{print $2}' | xargs kill -s SIGINT`; sleep 1; cnt=`ps -ef | grep -v grep |grep test.py | wc -l`;echo $cnt;done
cnt=1;while (($cnt > 0)) ;do for pid in `ps -ef | grep test.py | grep -v grep | awk "{print $2}"`;do echo "kill the $pid process" ;kill -2 $pid; done; sleep 1; cnt=`ps -ef | grep -v grep |grep test.py | wc -l`;echo $cnt;done

猜你喜欢

转载自blog.csdn.net/u010649766/article/details/80103909