How to find out and kill all processes for a user?

Hi!

We are using AIX 5.3.

Can anyone please guide me to find out all the running processes for a specific user, say ' admin' and also kill them by force.

Thanks!
atech

ps -ef | grep username shows you the running processes
su - username and than kill -9 -1 kills them forced and brings you back to root. Obviously not a good idea to do this for root :slight_smile:

Regards
zxmaus

ps -ef | grep admin | awk '{ print $2 }' | xargs kill -9

or

kill -9 $( ps -ef | grep admin | awk '{ print $2 }' )
1 Like

Unless you are trying to shut down a system after a serious hardware problem there is never a reason to issue kill -9 to processes attached to a database.
Use the proper kill signals for your database engine and give the database engine time to respond.

When cleaning idle sessions follow the kill signals defined by your database engine in the correct order and give the database engine time to respond.

Obviously no problem issuing "kill -9" to orphan processes which have no database files open.

The below command is also useful ,

# kill -9 `ps -fu admin |awk '{ print $2 }'|grep -v PID`

Another version of the same script this one with while loop

USER=name_of_your_ser
ps -ef |grep $USER|while read n1 n2 n3; do kill -9 $n2; done

Again in larger text so people notice it:

nobody said this is a DB box and if it is, let us hope user admin is not the DB user :slight_smile:

Thanks Corona688 for your valuable suggestion :slight_smile:

I am sure when people ask how to kill a process they know what they are doing and what would be the outcome of it. We just showed theoretical ways to do what have been asked. Now, it's the OP's responsibility to be aware of what they are doing as we are completely unaware of the circumstances here.