home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3708 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  1.3 KB

  1. Xref: sparky comp.unix.shell:3708 comp.unix.questions:10560
  2. Path: sparky!uunet!cis.ohio-state.edu!rutgers!cmcl2!panix!alexis
  3. From: alexis@panix.com (Alexis Rosen)
  4. Newsgroups: comp.unix.shell,comp.unix.questions,netcom.general
  5. Subject: Re: Need Script To Kill Process Using Substring Of Application Name
  6. Message-ID: <1992Aug31.113416.8536@panix.com>
  7. Date: 31 Aug 92 11:34:16 GMT
  8. References: <x6gnwvc.westes@netcom.com>
  9. Organization: PANIX Public Access Unix, NYC
  10. Lines: 23
  11.  
  12. westes@netcom.com (Will Estes) writes:
  13. >Does anyone have a script that they could send to me that will take as
  14. >its input some substring and then kill any process you own that has that
  15. >substring in its application name?  So the script would do something
  16. >like:
  17.  
  18. >    ps guaxww | grep "some_substring"
  19.  
  20. >then it would exclude the line that contained the grep command, locate
  21. >the PID of the remaining processes, and kill each one.  Please post the
  22. >script for others to see if its short enough.
  23.  
  24. Here's one which I used for wasting hung gettys.
  25. kill `ps -furoot | awk '/getty/ && !/ps/ {printf "%s ",$2}'`
  26.  
  27. This is SysV, so you'll need to change the ps arguments and maybe the awk
  28. $2 to $something-else.
  29.  
  30. --
  31. Alexis Rosen   Owner/Sysadmin,
  32. PANIX Public Access Unix & Internet, NYC.
  33. alexis@panix.com
  34. {uupsi,cmcl2}!panix!alexis
  35.