<?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 Simple Script Help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681527#M245463</link>
    <description>I have some processes that I want to kill on a daily basis, like:&lt;BR /&gt;#ps -ef | grep exec&lt;BR /&gt;&lt;BR /&gt;root 25098     1  0 01:00:01       ?    00:00:00 /usr/lib/mail/execmail root&lt;BR /&gt;&lt;BR /&gt;How can I pull out the pid and kill it?&lt;BR /&gt;&lt;BR /&gt;Also I want to kill all processes by a specific user named mmdf, like;&lt;BR /&gt;&lt;BR /&gt;# ps -fu mmdf&lt;BR /&gt; mmdf 25057   265  0 01:00:00       ?    00:00:00 sh -c  /usr/mmdf/bin/cleane&lt;BR /&gt;    mmdf 16861 25063  4 07:11:50       ?    00:01:02 submit&lt;BR /&gt;    mmdf 25063 25057  1 01:00:00       ?    00:22:28 /usr/mmdf/bin/cleanque&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 30 Nov 2005 07:46:25 GMT</pubDate>
    <dc:creator>Nobody's Hero</dc:creator>
    <dc:date>2005-11-30T07:46:25Z</dc:date>
    <item>
      <title>Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681527#M245463</link>
      <description>I have some processes that I want to kill on a daily basis, like:&lt;BR /&gt;#ps -ef | grep exec&lt;BR /&gt;&lt;BR /&gt;root 25098     1  0 01:00:01       ?    00:00:00 /usr/lib/mail/execmail root&lt;BR /&gt;&lt;BR /&gt;How can I pull out the pid and kill it?&lt;BR /&gt;&lt;BR /&gt;Also I want to kill all processes by a specific user named mmdf, like;&lt;BR /&gt;&lt;BR /&gt;# ps -fu mmdf&lt;BR /&gt; mmdf 25057   265  0 01:00:00       ?    00:00:00 sh -c  /usr/mmdf/bin/cleane&lt;BR /&gt;    mmdf 16861 25063  4 07:11:50       ?    00:01:02 submit&lt;BR /&gt;    mmdf 25063 25057  1 01:00:00       ?    00:22:28 /usr/mmdf/bin/cleanque&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Nov 2005 07:46:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681527#M245463</guid>
      <dc:creator>Nobody's Hero</dc:creator>
      <dc:date>2005-11-30T07:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681528#M245464</link>
      <description>Hi Robert:&lt;BR /&gt;&lt;BR /&gt;Use the UNIX95 (XPG4) form of 'ps' to find your processes by name:&lt;BR /&gt;&lt;BR /&gt;Suppose I want to look for a 'sleep' process owned by root:&lt;BR /&gt;&lt;BR /&gt;# PID=`UNIX95= ps -e -o pid,user,comm|awk '$2~/root/ &amp;amp;&amp;amp; $3~/sleep/ {print}'` &lt;BR /&gt;&lt;BR /&gt;Then:&lt;BR /&gt;&lt;BR /&gt;# if [ -z "${PID}" ]; then&lt;BR /&gt;&amp;gt; kill -1 ${PID} 2&amp;gt;/dev/null&lt;BR /&gt;&amp;gt; sleep 3&lt;BR /&gt;&amp;gt; kill -15 ${PID} 2&amp;gt;/dev/null&lt;BR /&gt;&amp;gt; sleep 3&lt;BR /&gt;&amp;gt; kill -9 ${PID} 2&amp;gt;/dev/null &lt;BR /&gt;&amp;gt; fi&lt;BR /&gt;&lt;BR /&gt;The above does more and more brutal kills.  If the process dies along the way, the redirection of STDERR eliminates seeing the "non-existent process" message.&lt;BR /&gt;&lt;BR /&gt;The last point is never to do a 'kill -9' except as a last restort.  A 'kill -9' cannot be trapped by a process leaving it no opportunity to free shared memory and/or remove any temporary files.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 30 Nov 2005 07:56:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681528#M245464</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-30T07:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681529#M245465</link>
      <description>Shalom Robert,&lt;BR /&gt;&lt;BR /&gt;A few ways to go. hopefullly there is something unique about the process.&lt;BR /&gt;&lt;BR /&gt;Lets say we want to kill a process named execmail&lt;BR /&gt;&lt;BR /&gt;PID=$(ps -ef | grep execmail | grep -v grep| awk '{print $2}'&lt;BR /&gt;&lt;BR /&gt;kill $PID&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;&lt;BR /&gt;You may need</description>
      <pubDate>Wed, 30 Nov 2005 07:56:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681529#M245465</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-11-30T07:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681530#M245466</link>
      <description>#ps -ef | grep exec | awk '{ print $2 }' &amp;gt; /tmp/kill_list&lt;BR /&gt;#for i in `cat /tmp/kill_list`&lt;BR /&gt;do&lt;BR /&gt;kill $i&lt;BR /&gt;sleep 1&lt;BR /&gt;kill -9 $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Same thing for a particular user.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Wed, 30 Nov 2005 07:57:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681530#M245466</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-11-30T07:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681531#M245467</link>
      <description>Hi (again) Robert:&lt;BR /&gt;&lt;BR /&gt;Also, note carefully that I wrote:&lt;BR /&gt;&lt;BR /&gt;# UNIX95= ps  ...&lt;BR /&gt;&lt;BR /&gt;There is a blank (space) character after the UNIX95= but *before* the 'ps'.  This limits the setting of the UNIX95 (XPG4) behavior to the command line on which it appears.  You don't want this setting to influence other commands without your explicit choice!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 30 Nov 2005 07:59:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681531#M245467</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-30T07:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681532#M245468</link>
      <description>Hi Robert:&lt;BR /&gt;&lt;BR /&gt;One correction.  I should have said "... print $1)'` as:&lt;BR /&gt;&lt;BR /&gt;# # PID=`UNIX95= ps -e -o pid,user,comm|awk '$2~/root/ &amp;amp;&amp;amp; $3~/sleep/ {print $1}'`&lt;BR /&gt;&lt;BR /&gt;This builds a list of 0 to n process IDs and allows seeking and killing in one pass.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Nov 2005 08:18:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681532#M245468</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-30T08:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681533#M245469</link>
      <description>note my latest typo&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PID=$(ps -ef | grep execmail | grep -v grep| awk '{print $2}'&lt;BR /&gt;&lt;BR /&gt;Needs to be&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PID=$(ps -ef | grep execmail | grep -v grep| awk '{print $2}')&lt;BR /&gt;&lt;BR /&gt;A minor but potentially disasterous problem.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 30 Nov 2005 08:19:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681533#M245469</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-11-30T08:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681534#M245470</link>
      <description>hi robert!&lt;BR /&gt;&lt;BR /&gt;see also the thread for the question that i had recently posted:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=969402" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=969402&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hope this helps too!&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Wed, 30 Nov 2005 08:27:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681534#M245470</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2005-11-30T08:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681535#M245471</link>
      <description>It is VERY important to *not* use grep or awk to find the processes! The reason is that grep and awk will not find just the process name, they will match user and group ID's, pathnames (ie, directories) and processes with the string somewhere in the name.&lt;BR /&gt; &lt;BR /&gt;The good news is that ps can perform an exact match for a process name, user and group ID, and eliminate potentially critical mistakes. For your first example:&lt;BR /&gt; &lt;BR /&gt;UNIX95=1 ps -C execmail -o pid,ruser,args&lt;BR /&gt; &lt;BR /&gt;will only find processes exactly named execmail (not rexecmail22 and other variations). Using the -o options helps to limit the required items of data. You can eliminate the title line for scripting by setting the label to null (-o pid= -o ruser= -o args=)</description>
      <pubDate>Wed, 30 Nov 2005 09:57:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681535#M245471</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-11-30T09:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681536#M245472</link>
      <description>BH, my emails to you bounce.&lt;BR /&gt;&lt;BR /&gt;I think grep can be made safe but...arguing with BH is a sure way to lose an argument.&lt;BR /&gt;&lt;BR /&gt;searchstring=$1&lt;BR /&gt;# make first input parameter the search string.&lt;BR /&gt;PID=$(UNIX95=1 ps -C $searchstring -o pid= -o ruser= -o args= | awk '{print $1}')&lt;BR /&gt;&lt;BR /&gt;kill $PID&lt;BR /&gt;&lt;BR /&gt;I also recommend not allow search parameters like root.&lt;BR /&gt;&lt;BR /&gt;Safer.&lt;BR /&gt;&lt;BR /&gt;BH approved?&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 30 Nov 2005 10:49:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-help/m-p/3681536#M245472</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-11-30T10:49:20Z</dc:date>
    </item>
  </channel>
</rss>

