Thursday, April 7, 2022

Kill multiple process using for loop

 Steps to kill multiple number of UNIX process using for loop

First important thing is make sure that killing those process will not impact any application or database.

step 1: create file with name - processlist

#cd /tmp

#vi processlist

12345

45677

98017

10078

10076

10056


save file by key sequence ESC and :wq


after file is saved, check that correct process id are entered.


#cat processlist

12345

45677

98017

10078

10076

10056


step 2:


while executing script make sure that you are in same path where "processlist" file is there


method 1:


for i in `cat processlist`

do

echo $i

kill -9 $i

sleep 2 

done


method 2:

using awk filter if u want to kill process related to "rpm" which are hung state then you can use following script


for i in `ps -eaf |grep -i "rpm"|awk '{print $2}'`

do

echo $i

kill -9 $i

sleep 2 

done


Monday, April 4, 2022

find 100% full filesystem using script on AIX LPAR

find 100% full filesystem using script on AIX LPAR

for i in `df -gi |grep -i '100%'|awk '{print $7}'`
do
echo "$i"
df -g $I
Sleep 2
done