- 论坛徽章:
- 0
|
有什么简便的方法kill 掉下面终端的所有进程?
我用的的方法比较繁复:
Cat killtty.sh
t000=$1
t001=` expr $t000 + 1 `
if [ $t001 -le 9 ]
then
t001=`echo "00$t001"`
fi
if [ $t001 -gt 9 ]
then
t001=`echo "0$t001"`
fi
t000=`echo "t$t000`
t001=`echo "t$t001`
cat /etc/inittab>/tmp/temp.txt
ed - /tmp/temp.txt > /tmp/temp0.txt <<!
/$t000
.,$ w /tmp/temp1.txt
q
!
ed - /tmp/temp1.txt >> /tmp/temp0.txt<<!
/$t000
.,$ w /tmp/temp1.txt
q
!
ed - /tmp/temp1.txt >> /tmp/temp0.txt<<!
/$t001
2,. w /tmp/temp2.txt
q
!
ed - /tmp/temp2.txt >> /tmp/temp0.txt<<!
$
d
w
q
!
cut -f1 -d: /tmp/temp2.txt |sed '/^#.*/d' > /tmp/temp1.txt
cat /tmp/temp1.txt
echo "终端进程:\c"
killttys="kill -9 "
for ttyp in `cat /tmp/temp1.txt`
do
ttypid=`ps -ef|grep tty$ttyp|grep -v grep|cut -c9-15`
echo " $ttypid\c"
killttys=`echo $killttys $ttypid`
done
echo "\n$killttys"
`$killttys`
echo "终端进程已 kill !!"
想请大家找一个更简单的方法! |
|