Does the program not have it's own method of killing processes, and if not why not (lazy programming?)? This is usually cleaner than using kill willy-nilly.
You'll probably need to write a script to handle that, and you'd better be very, very, careful with it. I have a personal aversion to automated killing of processes, because there's a good risk of "becoming famous", something no sys admin ever wants to do. To paraphrase Roger "Verbal" Kint (aka Keyser Soze): "The greatest trick a sys admin ever pulls is convincing his users that he doesn't exist." (s/his/her/g as needed)
Another possibility, if all of the processes access a common file (and no others do), would be to use the "fuser -k" command.
Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
to see if all <command> instances have the same pgid, then:
ps -ef -o pid,pgid,comm | grep <pgid found in step one>
to see if there are other processes you wouldn't want to kill in that group.
If killing the whole program group will work, then you can use the kill command in the following form. For this example, we'll kill (actually send interrupt signals to) all programs in program group 12345 with a SIGTERM (15) signal:
kill -15 -12345
SIGTERM is the default signal used by kill when you do a simple "kill <pid>". When killing a program group, the signal must be explicitly listed, or the group id will be interpreted as an invalid signal and no pid.
Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
i see, RodKnowlton excepted, nobody discovered the 'new' ps.
tell 'ps' to present you the output you need.
stop this, since s5r4 (ca 1995) obsolete, grep|awk carnival.
try, just for fun
(don't forget the SPACE in front of the 2nd / )
ps -efoargs,pid|sed -ne "s/.*WHAT-YOU-WANT.* //p"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.