Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

I am using the "ucbps" command I can get all PIDs

 $ ucbps

   Userid PID CPU % Mem % FD Used Server Port

   =========================================================================

   512 5783 2.50 16.30 350 managed1_adrrtwls02 61001

   512 8896 2.70 21.10 393 admin_adrrtwls02 61000

   512 9053 2.70 17.10 351 managed2_adrrtwls02 61002

I tried to do it like this, But have no idea how to do

  1. variable=get the pid from the process by process name.
  2. Then I used this command kill -9 variable.

1 Answer

0 votes
by (36.8k points)

To kill -9 based on the string you need to do something like this:

ps axf | grep <process name> | grep -v grep | awk '{print "kill -9 " $1}'

It will show you what you're going to kill  and the pipe will show when the time comes to execute:

ps axf | grep <process name> | grep -v grep | awk '{print "kill -9 " $1}' | sh

Want to be a Linux expert? Come and join this Linux course

Do check out the video below

 

 

Browse Categories

...