ps -ef | grep Insight3 > /tmp/killtxt.log
ps -ef | grep firefox >> /tmp/killtxt.log
cat /tmp/killtxt.log
cat /tmp/killtxt.log | while read lineStr
do
idStr=`echo $lineStr | awk '{print $4}'`
pidStr=`echo $lineStr | awk '{print $2}'`
if [ "$idStr" == "0" ]; then
echo "no need to kill $pidStr"
else
echo "kill $pidStr"
kill $pidStr
fi
done
ubuntu kill background running process
最新推荐文章于 2025-08-25 11:29:03 发布
本文介绍了一个简单的Shell脚本,该脚本用于查找并终止指定名称的进程。通过使用ps和grep命令组合,脚本能够将匹配的进程记录到日志文件中,并进一步筛选出需要终止的目标进程。
1824

被折叠的 条评论
为什么被折叠?



