<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Kill all? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502192#M21045</link>
    <description>Hi Ted:&lt;BR /&gt;&lt;BR /&gt;I would suggest that you do a "gentle" kill first, followed by a "kill -9" after waiting a few seconds.  This gives the processes being killed the ability to trap the termination signal and do any cleanup processing.&lt;BR /&gt;&lt;BR /&gt;If you build the list of PIDs to kill into a variable as, for instance, suggested by Chris, then you can do something like:&lt;BR /&gt;&lt;BR /&gt;kill $PIDLIST&lt;BR /&gt;sleep 5&lt;BR /&gt;kill -9 $PIDLIST 2&amp;gt; /dev/null&lt;BR /&gt;&lt;BR /&gt;Redirecting the stderr of the second kill to /dev/null suppresses any (or all) "process does not exist" messages for those already dead.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 07 Mar 2001 16:10:29 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2001-03-07T16:10:29Z</dc:date>
    <item>
      <title>Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502187#M21040</link>
      <description>Is it possible to write a script that would kill a specific group of users with one command?  I would like to be able to kill -9 a branch at a time.  Maybe I am just dreaming?  I run a HP9000 K220 box with HPUX 10.20 on it.  I guess the script would have to be able to tell who was on at the time of the process.  It gets old having to kill a group of users one at a time (25 or so) when a branch goes down.  Thanks!</description>
      <pubDate>Wed, 07 Mar 2001 13:34:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502187#M21040</guid>
      <dc:creator>Ted Flanders</dc:creator>
      <dc:date>2001-03-07T13:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502188#M21041</link>
      <description>Hi Ted,&lt;BR /&gt;&lt;BR /&gt;It is possible, you can search at processes with ps -ef |grep user.&lt;BR /&gt;After that you can search in the /etc/group file for the special user.&lt;BR /&gt;&lt;BR /&gt;Or you start the other way. first grep the group in the /etc/group, read those users of the group and grep in the proces list with this users. &lt;BR /&gt;&lt;BR /&gt;marcel</description>
      <pubDate>Wed, 07 Mar 2001 13:41:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502188#M21041</guid>
      <dc:creator>Marcel Boon</dc:creator>
      <dc:date>2001-03-07T13:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502189#M21042</link>
      <description>Hi there.&lt;BR /&gt;Perhaps you can try this little script :&lt;BR /&gt;&lt;BR /&gt;ps -ef|grep ${1}|grep -v grep | sort | awk |  '{print "kill -9 "$2}'&amp;gt; /usr/tmp/kill_em&lt;BR /&gt;&lt;BR /&gt;chmod 744 /usr/tmp/kill_em&lt;BR /&gt;&lt;BR /&gt;/usr/tmp/kill_em&lt;BR /&gt;&lt;BR /&gt;ps -ef|grep ${1}&lt;BR /&gt;&lt;BR /&gt;Only usable as superuser.&lt;BR /&gt;Rgds&lt;BR /&gt;Alexander M. Ermes&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Mar 2001 13:54:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502189#M21042</guid>
      <dc:creator>Alexander M. Ermes</dc:creator>
      <dc:date>2001-03-07T13:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502190#M21043</link>
      <description>Try ee=`ps -e|grep processname|cut -c2-6`&lt;BR /&gt;      kill -9   $ee</description>
      <pubDate>Wed, 07 Mar 2001 15:30:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502190#M21043</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2001-03-07T15:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502191#M21044</link>
      <description>My fav is this,&lt;BR /&gt;&lt;BR /&gt;ps -ef |grep username |awk '{print $2}' |xargs kill -9&lt;BR /&gt;&lt;BR /&gt;=]</description>
      <pubDate>Wed, 07 Mar 2001 15:36:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502191#M21044</guid>
      <dc:creator>Charles Darnell</dc:creator>
      <dc:date>2001-03-07T15:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502192#M21045</link>
      <description>Hi Ted:&lt;BR /&gt;&lt;BR /&gt;I would suggest that you do a "gentle" kill first, followed by a "kill -9" after waiting a few seconds.  This gives the processes being killed the ability to trap the termination signal and do any cleanup processing.&lt;BR /&gt;&lt;BR /&gt;If you build the list of PIDs to kill into a variable as, for instance, suggested by Chris, then you can do something like:&lt;BR /&gt;&lt;BR /&gt;kill $PIDLIST&lt;BR /&gt;sleep 5&lt;BR /&gt;kill -9 $PIDLIST 2&amp;gt; /dev/null&lt;BR /&gt;&lt;BR /&gt;Redirecting the stderr of the second kill to /dev/null suppresses any (or all) "process does not exist" messages for those already dead.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 07 Mar 2001 16:10:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502192#M21045</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-03-07T16:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502193#M21046</link>
      <description>So.....forgive me here but.....I want to be able to type in, for example: kill_seattle&lt;BR /&gt;and have it kill all users from the seattle branch.  So, I would name the script kill_seattle and list usernames to grep?  Can you tell that I am inexperienced at this!?!</description>
      <pubDate>Wed, 07 Mar 2001 17:31:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502193#M21046</guid>
      <dc:creator>Ted Flanders</dc:creator>
      <dc:date>2001-03-07T17:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502194#M21047</link>
      <description>Hi Ted:&lt;BR /&gt;&lt;BR /&gt;Assuming you want to predefine the users in your branch, you could do something simple like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;SEATTLE="-e usr1 -e usr2 -e usr3"&lt;BR /&gt;PIDLIST=`ps -ef|grep $WHO|grep -v grep|awk '{print $2}'`&lt;BR /&gt;kill $PIDLIST&lt;BR /&gt;sleep 5&lt;BR /&gt;kill -9 $PIDLIST&lt;BR /&gt;#.end.&lt;BR /&gt;&lt;BR /&gt;The '-e' option allows multiple arguments; and the '-v' option filters out finding the 'grep' process you're running.  Watch out for matches to users you don't want.  For example, "usr" would match anything in the example script.  You could always use regular expressions like:&lt;BR /&gt;&lt;BR /&gt;[[:space:]]usr1[[:space:]]&lt;BR /&gt;&lt;BR /&gt;in lieu of simply "usr1" if/as needed.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 07 Mar 2001 18:20:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502194#M21047</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-03-07T18:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502195#M21048</link>
      <description>Hmmm,&lt;BR /&gt;&lt;BR /&gt;What about:&lt;BR /&gt;&lt;BR /&gt;kill `ps -u id1 id2 id3 | awk '{ print $1}'`&lt;BR /&gt;&lt;BR /&gt;Volker</description>
      <pubDate>Wed, 07 Mar 2001 18:28:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502195#M21048</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-03-07T18:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502196#M21049</link>
      <description>... to be added,&lt;BR /&gt;&lt;BR /&gt;"ps -ef | grep user_to_kill" as selection base&lt;BR /&gt;might kill a process with the name /home/user_to_kill/job.sh although it is executed by user_never_to_be_killed !&lt;BR /&gt;&lt;BR /&gt;May be some scripts should be adjusted ?&lt;BR /&gt;( ok, may be a rare case :-)&lt;BR /&gt;&lt;BR /&gt;Volker</description>
      <pubDate>Wed, 07 Mar 2001 18:35:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502196#M21049</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-03-07T18:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502197#M21050</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Here's another way to make the filtering of the 'ps' output more rigorous; choose the processes by user name and first issue a simple kill to allow the process to attempt to cleanup:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;PIDLIST=``ps -ef|awk '$1~/^usr1$/||$1~/^usr2$/||$1~/^usr3$/ {print $2}'`&lt;BR /&gt;kill $PIDLIST &lt;BR /&gt;sleep 5 &lt;BR /&gt;kill -9 $PIDLIST&lt;BR /&gt;#.end.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 07 Mar 2001 19:54:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502197#M21050</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-03-07T19:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502198#M21051</link>
      <description>If you are looking for a way to kill the processes running by users within a specific group defined in /etc/groups I personally use this (not sure how well this will paste in).  Basically it cats the group file and parses it and then runs a for loop to kill all processes that each user is running.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;if [ "$2" = "" ]; then&lt;BR /&gt;  SIG="-TERM"&lt;BR /&gt;else&lt;BR /&gt;  SIG="$2"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ "$1" = "" ]; then&lt;BR /&gt;  echo "Usage: $0 &lt;GROUP to="" kill=""&gt; &lt;SIGNAL to="" send=""&gt;"&lt;BR /&gt;  exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;WHO=`cat group | grep ^$1: | awk -F: '{ print $4 }' | sed s/,/\ /g`&lt;BR /&gt;&lt;BR /&gt;for i in $WHO; do&lt;BR /&gt;  kill $SIG `ps aux | grep $i | grep -v grep | awk '{ print $2 }'`&lt;BR /&gt;done&lt;BR /&gt;&lt;/SIGNAL&gt;&lt;/GROUP&gt;</description>
      <pubDate>Thu, 08 Mar 2001 00:31:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502198#M21051</guid>
      <dc:creator>Keith Bunge</dc:creator>
      <dc:date>2001-03-08T00:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502199#M21052</link>
      <description>Sorry about that I had taken out all the references to NIS in that script, this is how it should read.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;if [ "$2" = "" ]; then&lt;BR /&gt;  SIG="-TERM"&lt;BR /&gt;else&lt;BR /&gt;  SIG="$2"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ "$1" = "" ]; then&lt;BR /&gt;  echo "Usage: $0 &lt;GROUP to="" kill=""&gt; &lt;SIGNAL to="" send=""&gt;"&lt;BR /&gt;  exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;WHO=`cat /etc/group | grep ^$1: | awk -F: '{ print $4 }' | sed s/,/\ /g`&lt;BR /&gt;&lt;BR /&gt;for i in $WHO; do&lt;BR /&gt;  kill $SIG `ps -ef | grep $i | grep -v grep | awk '{ print $2 }'`&lt;BR /&gt;done&lt;BR /&gt;&lt;/SIGNAL&gt;&lt;/GROUP&gt;</description>
      <pubDate>Thu, 08 Mar 2001 00:36:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502199#M21052</guid>
      <dc:creator>Keith Bunge</dc:creator>
      <dc:date>2001-03-08T00:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502200#M21053</link>
      <description>Thanks all, for your help.  Time to start testing these scripts!  I hope I assigned points correctly.  With multiple answers from the same person, I gave half the total points to some answers, add them both up for the total points given.  I think that is the right way to do it.  Otherwise some people would recieve 20 or 30 points for multiple answers.  I dont know, let me know if this is ok, I guess you do take the time to answer. Once again, I dont know what I would do without your expertise!</description>
      <pubDate>Thu, 08 Mar 2001 13:24:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502200#M21053</guid>
      <dc:creator>Ted Flanders</dc:creator>
      <dc:date>2001-03-08T13:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502201#M21054</link>
      <description>Hey Ted,&lt;BR /&gt;&lt;BR /&gt;your fine with the points, although if it is a real solution within one answer, it deserves at least 8 points (to show up the bunny). &lt;BR /&gt;&lt;BR /&gt;If there is a second quote just for additional information, you could choose to add N/A (as you should do for this one), to keep your assignment statistics up to date.&lt;BR /&gt;But, if the additional information has good quality, it is also okay to assign additional points.&lt;BR /&gt;You will find several messages in this forum, which are over-pointed in my opinion. I.e the jokes that show up from time to time. But on the other hand, some of those are really good, so why not (I imagine this HP-McDonalds comparison a few days ago :~) &lt;BR /&gt;That was a well deserved 10 for Rick ....&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Volker&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Mar 2001 14:17:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502201#M21054</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-03-08T14:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502202#M21055</link>
      <description>Dave Fargo using Les's ITRC login..&lt;BR /&gt;&lt;BR /&gt;Do everything possible to prevent selecting an unintended process for automated kill.&lt;BR /&gt;&lt;BR /&gt;Use 'ps' options (user, group, etc.) to limit the selection first, relying on 'grep' only as absolutely necessary.  Using 'grep &lt;USERNAME&gt;' alone may select processes for other UIDs, if the name is embedded in the process information (IE the directory path to the file being executed), or if you have very similar ID names, such as user1, user10, user11.&lt;BR /&gt;&lt;BR /&gt;Also, once a process is identified for kill, store the process information and use it to verify that the PID still refers to what you want before issuing a kill.  When killing groups of processes, parent/child relationships can cause several to die from one kill command, freeing the process table entry for the PID, which could then get grabbed by a new unrelated process.  So the script should be smart enough to check that what it first selected is still what is active for the PID.&lt;BR /&gt;&lt;BR /&gt;2 or more loops through the PIDs is a good idea, first doing soft kills, then any app-specific kills, finally the -9 option.&lt;/USERNAME&gt;</description>
      <pubDate>Thu, 08 Mar 2001 18:05:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502202#M21055</guid>
      <dc:creator>Les Schuettpelz</dc:creator>
      <dc:date>2001-03-08T18:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Kill all?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502203#M21056</link>
      <description>Hi Keith Bunge,&lt;BR /&gt;I had tried your script but it is not able to capture users in the primary as the /etc/group only shows the secondary group with userids. How should I check for the primary group users? As I had 2 group ids of 100 and 1000 and when I did a grep 100 on /etc/passwd it captures all the users in the group 100 and 1000 which is not what I want. Any advise? Thanks.&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Aug 2002 02:52:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/kill-all/m-p/2502203#M21056</guid>
      <dc:creator>Yvonne Chan</dc:creator>
      <dc:date>2002-08-29T02:52:46Z</dc:date>
    </item>
  </channel>
</rss>

