<?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: pkill equivalent? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964713#M292191</link>
    <description>&lt;!--!*#--&gt;Here you go.  I've been using this for years.  It will show you what it's going to kill and prompt for your approval.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#pkill - kill processes matching pattern&lt;BR /&gt;&lt;BR /&gt;prgName=$(basename $0)&lt;BR /&gt;TMPFILE=/tmp/$prgName.$$&lt;BR /&gt;&lt;BR /&gt;syntax()&lt;BR /&gt;{&lt;BR /&gt;cat &amp;lt;&amp;lt; EOH&lt;BR /&gt;Usage:&lt;BR /&gt;  pkill [-p] [-s sig] pattern&lt;BR /&gt;Description:&lt;BR /&gt;  Kill all processes in output of 'ps -ef' that match pattern.&lt;BR /&gt;Options:&lt;BR /&gt;    -p      Match pattern only to process names (use output&lt;BR /&gt;            of 'ps -e').&lt;BR /&gt;    -s sig  Send this signal; if not specified, -9 is used&lt;BR /&gt;EOH&lt;BR /&gt;    exit&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;unset procs_only&lt;BR /&gt;sig=-9&lt;BR /&gt;&lt;BR /&gt;while getopts ps: opt ; do&lt;BR /&gt;    case $opt in&lt;BR /&gt;        p)  procs_only=TRUE ;;&lt;BR /&gt;        s)  sig=$OPTARG ;;&lt;BR /&gt;        *)  syntax ;;&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;shift $(( $OPTIND-1 ))&lt;BR /&gt;[ -z "$*" ] &amp;amp;&amp;amp; syntax&lt;BR /&gt;&lt;BR /&gt;if [ -n "$procs_only" ] ; then&lt;BR /&gt;    ps -e | grep "$*" | nl -s":" &amp;gt; $TMPFILE&lt;BR /&gt;else&lt;BR /&gt;    ps -ef | grep "$*" | egrep -v "grep|$prgName" &amp;gt; $TMPFILE&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -s $TMPFILE ] ; then&lt;BR /&gt;    sed 's/  / /g' $TMPFILE&lt;BR /&gt;    echo "Send kill $sig?  Press [Ctl][C] to abort, [Enter] to procede &amp;gt;\c"&lt;BR /&gt;    read a&lt;BR /&gt;    cat $TMPFILE | awk '{ print $2 }' | xargs kill $sig&lt;BR /&gt;else&lt;BR /&gt;    echo "$prgName: \"$*\" no matching processes found."&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;rm $TMPFILE</description>
    <pubDate>Tue, 20 Mar 2007 01:58:06 GMT</pubDate>
    <dc:creator>Eric Raeburn</dc:creator>
    <dc:date>2007-03-20T01:58:06Z</dc:date>
    <item>
      <title>pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964708#M292186</link>
      <description>&lt;BR /&gt;What is the hp-ux equivalent of sun's pkill? I cannot find pkill anywhere on the 11.23 system.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Mar 2007 15:00:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964708#M292186</guid>
      <dc:creator>dictum9</dc:creator>
      <dc:date>2007-03-19T15:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964709#M292187</link>
      <description>What does pkill on Solaris do?  If we have an idea of the function, we may be able to suggest an HP-UX equivalent.</description>
      <pubDate>Mon, 19 Mar 2007 15:09:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964709#M292187</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-03-19T15:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964710#M292188</link>
      <description>There is no direct equivalent for this non-standard command but it is very easy to craft an equivalent leveraging the XPG4 behavior of ps:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;COMM=${1}&lt;BR /&gt;shift&lt;BR /&gt;UNIX95=1 ps -C ${COMM} -o pid='' | while read P&lt;BR /&gt;  do&lt;BR /&gt;     kill -15 ${P}&lt;BR /&gt;  done&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Mar 2007 15:10:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964710#M292188</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-03-19T15:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964711#M292189</link>
      <description>you are going to have to get the pid(s) of the process(es) you want to kill and then use the kill command to terminate the process(es). Or you could write your own script that works like pkill.</description>
      <pubDate>Mon, 19 Mar 2007 15:12:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964711#M292189</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-03-19T15:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964712#M292190</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;There isn't a direct counterpart.  However, you can/should leverage the UNIX95 behavior of 'ps' to find a process by name :&lt;BR /&gt;&lt;BR /&gt;# UNIX95= ps -C cron -o pid=&lt;BR /&gt;&lt;BR /&gt;For example, the above will return the 'pid' of the 'cron' daemon.  The match is *exactly* to the basename of a process and no other.  The '-o pid=' signifies that all you want shown is the 'pid'(s) of processes by the name of the '-C' switch's argument.&lt;BR /&gt;&lt;BR /&gt;The equal sign after the 'pid' argument means suppress the heading line from 'ps'.&lt;BR /&gt;&lt;BR /&gt;There is a space (or tab) after UNIX95=.  This limits the UNIX95 behavior to the command line only.&lt;BR /&gt;&lt;BR /&gt;Given that you find the correct pid for the correct process, you can proceed to gently 'kill' the process.  That is, begin with a simple 'kill -hup' and then a 'kill -term' and *only* as a last resort, a 'kill -9'.  Remember that at 'kill -9' cannot be trapped and may leave shared memory segments and/or temporary files abandoned!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 19 Mar 2007 15:15:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964712#M292190</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-19T15:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964713#M292191</link>
      <description>&lt;!--!*#--&gt;Here you go.  I've been using this for years.  It will show you what it's going to kill and prompt for your approval.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#pkill - kill processes matching pattern&lt;BR /&gt;&lt;BR /&gt;prgName=$(basename $0)&lt;BR /&gt;TMPFILE=/tmp/$prgName.$$&lt;BR /&gt;&lt;BR /&gt;syntax()&lt;BR /&gt;{&lt;BR /&gt;cat &amp;lt;&amp;lt; EOH&lt;BR /&gt;Usage:&lt;BR /&gt;  pkill [-p] [-s sig] pattern&lt;BR /&gt;Description:&lt;BR /&gt;  Kill all processes in output of 'ps -ef' that match pattern.&lt;BR /&gt;Options:&lt;BR /&gt;    -p      Match pattern only to process names (use output&lt;BR /&gt;            of 'ps -e').&lt;BR /&gt;    -s sig  Send this signal; if not specified, -9 is used&lt;BR /&gt;EOH&lt;BR /&gt;    exit&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;unset procs_only&lt;BR /&gt;sig=-9&lt;BR /&gt;&lt;BR /&gt;while getopts ps: opt ; do&lt;BR /&gt;    case $opt in&lt;BR /&gt;        p)  procs_only=TRUE ;;&lt;BR /&gt;        s)  sig=$OPTARG ;;&lt;BR /&gt;        *)  syntax ;;&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;shift $(( $OPTIND-1 ))&lt;BR /&gt;[ -z "$*" ] &amp;amp;&amp;amp; syntax&lt;BR /&gt;&lt;BR /&gt;if [ -n "$procs_only" ] ; then&lt;BR /&gt;    ps -e | grep "$*" | nl -s":" &amp;gt; $TMPFILE&lt;BR /&gt;else&lt;BR /&gt;    ps -ef | grep "$*" | egrep -v "grep|$prgName" &amp;gt; $TMPFILE&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -s $TMPFILE ] ; then&lt;BR /&gt;    sed 's/  / /g' $TMPFILE&lt;BR /&gt;    echo "Send kill $sig?  Press [Ctl][C] to abort, [Enter] to procede &amp;gt;\c"&lt;BR /&gt;    read a&lt;BR /&gt;    cat $TMPFILE | awk '{ print $2 }' | xargs kill $sig&lt;BR /&gt;else&lt;BR /&gt;    echo "$prgName: \"$*\" no matching processes found."&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;rm $TMPFILE</description>
      <pubDate>Tue, 20 Mar 2007 01:58:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964713#M292191</guid>
      <dc:creator>Eric Raeburn</dc:creator>
      <dc:date>2007-03-20T01:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964714#M292192</link>
      <description>&lt;!--!*#--&gt;Actually, my script would be better if it piped ps through egrep instead of grep.  Then it could be used to kill process names matching more than one pattern:&lt;BR /&gt;&lt;BR /&gt;    pkill "this|that|the_other"&lt;BR /&gt;&lt;BR /&gt;-Eric</description>
      <pubDate>Tue, 20 Mar 2007 02:04:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964714#M292192</guid>
      <dc:creator>Eric Raeburn</dc:creator>
      <dc:date>2007-03-20T02:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964715#M292193</link>
      <description>pkill is available on 11.31.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Eric: my script would be better if it piped ps through egrep instead of grep.&lt;BR /&gt;pkill "this|that|the_other"&lt;BR /&gt;&lt;BR /&gt;There is no reason to use an egrep hammer for this.  Unless you want that interface in your script.  (It appears you might.)&lt;BR /&gt;&lt;BR /&gt;You can simply use: grep -e this -e that -e the_other</description>
      <pubDate>Tue, 20 Mar 2007 02:34:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964715#M292193</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-20T02:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: pkill equivalent?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964716#M292194</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hpux.ws/gkill" target="_blank"&gt;http://www.hpux.ws/gkill&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 20 Mar 2007 03:03:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pkill-equivalent/m-p/3964716#M292194</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-03-20T03:03:04Z</dc:date>
    </item>
  </channel>
</rss>

