详见附件.
#!/bin/bash
checktime=6
filterNum=5
proc_name=particularImgMain
i=0
while [ $i -lt $filterNum ]
do
res=$(ps aux|grep $proc_name|grep -v grep)
pid=$(echo $res | awk '{print $2}')
kill $pid
while [ 1 ]
do
str=$(ps aux|grep $proc_name|grep $pid|grep -v grep)
if [ ! "$str" ]
then
echo "$pid killed successfully"
break
fi
echo "wait kill $pid $i, sleep $checktime sec"
sleep $checktime
done
let "i=i+1"
done
#!/bin/bash
checktime=6
filterNum=5
proc_name=particularImgMain
i=0
while [ $i -lt $filterNum ]
do
res=$(ps aux|grep $proc_name|grep -v grep)
pid=$(echo $res | awk '{print $2}')
kill $pid
while [ 1 ]
do
str=$(ps aux|grep $proc_name|grep $pid|grep -v grep)
if [ ! "$str" ]
then
echo "$pid killed successfully"
break
fi
echo "wait kill $pid $i, sleep $checktime sec"
sleep $checktime
done
let "i=i+1"
done
本文介绍了一个使用Shell脚本实现的进程管理工具。该脚本能够循环查找并终止指定名称的进程,确保进程被完全关闭。通过设置检查时间和过滤数量等参数,可以灵活控制进程的查找与终止过程。
724

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



