使用bash检查进程是否正在脚本中运行的最简单,最可靠的方法是什么?
这是我所拥有的:
x=`ps aux | grep firefox | grep -v grep | awk '{print $2 }'`
if [ $x > 0 ];
then kill -9 $x
echo "Firefox terminated"
else echo "bla bla bla"
fi
if x=$(pgrep firefox); then
kill -9 $x
# ...
fi
如果您只想终止该过程:
pkill -9 firefox
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句