Hi,
Sometimes you need to kill all processes of any user in linux.
Normally you can kill any process from its PID like following.
[root@MehmetSalih ~]# ps -ef | grep OSWatcher.sh
root 4183 1 6 May02 ? 20:13:56 /bin/sh ./OSWatcher.sh 10 504 gzip /opt/oracle/oak/oswbb/archive
root 73811 4183 15 16:10 ? 00:00:00 /bin/sh ./OSWatcher.sh 10 504 gzip /opt/oracle/oak/oswbb/archive
root 73813 73811 13 16:10 ? 00:00:00 [OSWatcher.sh]
root 73816 92104 0 16:10 pts/1 00:00:00 grep OSWatcher.sh
[root@MehmetSalih ~]#
[root@MehmetSalih ~]# kill -9 4183
-bash: kill: (4183) - No such process
[root@MehmetSalih ~]#
But sometimes you need killing all processes of any user , then you can use following code.
[root@MehmetSalih ~]# kill -9 `ps -ef|grep oracle | awk '{print $2}'`
I have used Oracle user in this example, you can change username according to your need.
Dont’t forget that you will have killed ALL PROCESSES OF ANY USER, so Be careful before run it.
For example, You have stopped Oracle EBS with adstpall.sh, but you have still EBS Process belong to applmgr, You can kill all processes of applmgr user like following.
[root@MehmetSalih ~]# kill -9 `ps -ef|grep applmgr | awk '{print $2}'`
Or you can use following command.
[root@MehmetSalih ~]# pkill -u applmgr [root@MehmetSalih ~]# pkill -u oracle
Do you want to learn Linux System Administration for Beginners, then read the following articles.
https://ittutorial.org/linux-administration-tutorial-for-beginners/
Careful – something like this is apt to select the wrong processes since you will match text from the whole line. Maybe you should have used formatting “ps -e -o user,pid” or use “pkill -u” which is already made for this.
A construct such as ” kill -9 `ps -ef|grep oracle | awk ‘{print $2}’`” is totally not needed, just use “pkill -u oracle”. >_<