LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Process killing script (https://www.linuxquestions.org/questions/linux-general-1/process-killing-script-344667/)

owix 07-19-2005 10:34 AM

Process killing script
 
Hello everybody:

I am running a software which usually leaves undesired processes running after progam shutdown, always containing the directory where the binaries running are placed. I usually kill them by

> ps aux | grep my-
owix 28346 0.0 0.6 72608 6788 ? S 17:24 0:00 /work/my-release/my_dir/installed/i686-slc3-gcc323-opt/bin/rc_empty_controller
owix 28347 0.0 0.6 93220 6948 ? S 17:24 0:00 /work/my-release/my_dir/installed/i686-slc3-gcc323-opt/bin/rc_empty_controller -n RootController
owix 28575 0.0 0.0 4772 680 pts/5 S 17:27 0:00 grep my-

and then:

> kill -9 28347 28346

Then I would like to have an script which kill all the processes belonging to a specific user (owix) and that contains in the description the "my-release" pattern.
Do you have any idea about how to do this? Thanks you very much. Cheers,

OWIX

hamish 07-19-2005 11:04 AM

ps aux | grep my-owix > tempfile

then use awk to select the first colum from that temp file. Can't quite remember the code, but it iwll be something like:

awk '{ print $1 }' tempfile > temp2

then write a script to get the PID from temp2.

hamish

demian 07-19-2005 11:08 AM

ps aux|grep owix|grep [m]y-release|awk '{print $2}'|xargs kill -9


All times are GMT -5. The time now is 04:01 AM.