<?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: user process in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126419#M315599</link>
    <description>&amp;gt;but if it fail to kill, it pop the message PID is not alive&lt;BR /&gt;&lt;BR /&gt;The "kill -0", doesn't kill it, it checks the PID existance.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;but it seems not try to kill again by kill -1, it seems the script is stopped at that time&lt;BR /&gt;&lt;BR /&gt;If the PID isn't there, it does no good to try to kill it.&lt;BR /&gt;To prove this, you could add: ps -fu $PID</description>
    <pubDate>Mon, 14 Jan 2008 09:55:57 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2008-01-14T09:55:57Z</dc:date>
    <item>
      <title>user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126411#M315591</link>
      <description>I hv existing script to generate some pid to a file, the below is the format of the file ,&lt;BR /&gt;&lt;BR /&gt;$vi pid_file&lt;BR /&gt;15484&lt;BR /&gt;4521&lt;BR /&gt;&lt;BR /&gt;now I would like to have a script to kill all process , I would like to use the command "kill" first , if can't kill it , then use "kill -1" , if still can't then use "kill -3" , if still not then send mail to administrator , can advise what can i write the script ? thx .</description>
      <pubDate>Wed, 09 Jan 2008 09:21:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126411#M315591</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-09T09:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126412#M315592</link>
      <description>Here is logic for what you want: &lt;BR /&gt;&lt;BR /&gt;Read file under script and use kill process under case structure with default case to sendmail. Use echo $? to check id process is killed or not and then accordingle proceed.&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Jan 2008 09:33:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126412#M315592</guid>
      <dc:creator>Shrikant Lavhate</dc:creator>
      <dc:date>2008-01-09T09:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126413#M315593</link>
      <description>hi ust3:&lt;BR /&gt;&lt;BR /&gt;try this:&lt;BR /&gt;&lt;BR /&gt;if -z pid_file&lt;BR /&gt;then&lt;BR /&gt;for i in `cat pid_file`&lt;BR /&gt;do&lt;BR /&gt;kill $i&lt;BR /&gt;done&lt;BR /&gt;fi&lt;BR /&gt;if -z pid_file&lt;BR /&gt;then&lt;BR /&gt;mailx ....&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;or this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;kill $(ps -fu &lt;USER&gt;|awk {'print $2'})&lt;BR /&gt;&lt;BR /&gt;regards&lt;/USER&gt;</description>
      <pubDate>Wed, 09 Jan 2008 09:38:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126413#M315593</guid>
      <dc:creator>Roberto Arias</dc:creator>
      <dc:date>2008-01-09T09:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126414#M315594</link>
      <description>first think which process and which user process you want to kill.&lt;BR /&gt;&lt;BR /&gt;Here is a command with arguments which kill all user process at a glance&lt;BR /&gt;&lt;BR /&gt;#ps -ef | awk '{print $1" "$2}' | grep &lt;USER&gt; | awk '{print $NF}' | xargs kill&lt;BR /&gt;&lt;BR /&gt;be careful to use this command.&lt;/USER&gt;</description>
      <pubDate>Wed, 09 Jan 2008 09:48:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126414#M315594</guid>
      <dc:creator>Jeeshan</dc:creator>
      <dc:date>2008-01-09T09:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126415#M315595</link>
      <description>&lt;!--!*#--&gt;Try something like this.  Remove echo before kill if happy.  Add a "false" after the echo to go to the next step.&lt;BR /&gt;for PID in $(&amp;lt; pid_file); do&lt;BR /&gt;   kill -0 $PID 2&amp;gt; /dev/null&lt;BR /&gt;   if [ $? -ne 0 ]; then&lt;BR /&gt;      echo "PID $PID is not alive"&lt;BR /&gt;      continue&lt;BR /&gt;   fi&lt;BR /&gt;   echo kill $PID&lt;BR /&gt;   false  # remove after script tested&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo kill -INT $PID&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo kill -QUIT $PID&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo mailx -s "Problem killing process" root &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;Problem killing $PID.&lt;BR /&gt;EOF&lt;BR /&gt;done</description>
      <pubDate>Wed, 09 Jan 2008 10:48:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126415#M315595</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-09T10:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126416#M315596</link>
      <description>thx replies,&lt;BR /&gt;&lt;BR /&gt;I am trying the script&lt;BR /&gt;for PID in $(&amp;lt; pid_file); do&lt;BR /&gt;   kill -0 $PID 2&amp;gt; /dev/null&lt;BR /&gt;   if [ $? -ne 0 ]; then&lt;BR /&gt;      echo "PID $PID is not alive"&lt;BR /&gt;      continue&lt;BR /&gt;   fi&lt;BR /&gt;   echo kill $PID&lt;BR /&gt;   false  # remove after script tested&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo kill -INT $PID&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo kill -QUIT $PID&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo mailx -s "Problem killing process" root &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;Problem killing $PID.&lt;BR /&gt;EOF&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;But I found the process only run the first part &lt;BR /&gt;&lt;BR /&gt;  echo $PID&lt;BR /&gt;  kill -0 $PID 2&amp;gt; /dev/null&lt;BR /&gt;   if [ $? -ne 0 ]; then&lt;BR /&gt;     echo "PID $PID is not alive"&lt;BR /&gt;      continue&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;what I want is if the parocess is not killed , then run kill -1 , then kill -3 , if still not , then send me a mail , please help again. thx&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jan 2008 08:24:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126416#M315596</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-14T08:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126417#M315597</link>
      <description>&lt;!--!*#--&gt;&amp;gt;But I found the process only run the first part&lt;BR /&gt;kill -0 $PID 2&amp;gt; /dev/null&lt;BR /&gt;if [ $? -ne 0 ]; then&lt;BR /&gt;   echo "PID $PID is not alive"&lt;BR /&gt;   continue&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;If it only does this, then that PID doesn't exist.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;what I want is if the process is not killed, ...&lt;BR /&gt;&lt;BR /&gt;That part is there.</description>
      <pubDate>Mon, 14 Jan 2008 08:52:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126417#M315597</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-14T08:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126418#M315598</link>
      <description>thx Dennis ,&lt;BR /&gt;&lt;BR /&gt;I tried the script , it try to kill the PID , but if it fail to kill , it pop the message PID is not alive , it works fine , but it seems not try to kill again by kill -1 , it seems the script is stopped at that time , and do not run the rest part of it (eg.   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo kill -INT $PID) , can advise what is wrong ? thx&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jan 2008 09:30:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126418#M315598</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-14T09:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126419#M315599</link>
      <description>&amp;gt;but if it fail to kill, it pop the message PID is not alive&lt;BR /&gt;&lt;BR /&gt;The "kill -0", doesn't kill it, it checks the PID existance.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;but it seems not try to kill again by kill -1, it seems the script is stopped at that time&lt;BR /&gt;&lt;BR /&gt;If the PID isn't there, it does no good to try to kill it.&lt;BR /&gt;To prove this, you could add: ps -fu $PID</description>
      <pubDate>Mon, 14 Jan 2008 09:55:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126419#M315599</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-14T09:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126420#M315600</link>
      <description>thx dennis,&lt;BR /&gt;&lt;BR /&gt;I have problem to use kill -0 to check the existence of pid , can advise if I want to skip this checking , what I want is to kill the pid by kill -1 first , if can't then kill -2 , then kill -3 , can advise can can I modify it? thx&lt;BR /&gt;&lt;BR /&gt;how to skip the below part from the script&lt;BR /&gt;==========================================&lt;BR /&gt;kill -0 $PID 2&amp;gt; /dev/null&lt;BR /&gt;if [ $? -ne 0 ]; then&lt;BR /&gt;   echo "PID $PID is not alive"&lt;BR /&gt;   continue&lt;BR /&gt;fi</description>
      <pubDate>Tue, 15 Jan 2008 05:49:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126420#M315600</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-15T05:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126421#M315601</link>
      <description>&amp;gt;can advise if I want to skip this checking&lt;BR /&gt;&lt;BR /&gt;You can just remove this "kill -0 if ... fi" block of code.  But you'll get a mail message.</description>
      <pubDate>Tue, 15 Jan 2008 05:54:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126421#M315601</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-15T05:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126422#M315602</link>
      <description>thx dennis ,&lt;BR /&gt;&lt;BR /&gt;I am not understand what is the use the that part of script &lt;BR /&gt;&lt;BR /&gt;===========================================&lt;BR /&gt; kill  $PID 2&amp;gt; /dev/null&lt;BR /&gt;    if [ $? -eq 0  ]; then continue; fi&lt;BR /&gt;===========================================&lt;BR /&gt;is it mean ?&lt;BR /&gt;if it fail to kill the PID , then its output = 0 , then do next loop kill -INT ?&lt;BR /&gt;but in my mind , the logic should be if it is successful kill PID , the output should be = 0 , that should not go to next loop .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Jan 2008 06:19:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126422#M315602</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-15T06:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126423#M315603</link>
      <description>&amp;gt;I am not understand what is the use the that part of script&lt;BR /&gt;kill $PID 2&amp;gt; /dev/null&lt;BR /&gt;if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;&amp;gt;if it fail to kill the PID, then its output = 0, then do next loop kill -INT?&lt;BR /&gt;&lt;BR /&gt;If kill works, its exit status is 0 and then it continues to the next iteration of the loop.&lt;BR /&gt;(This is goto/break/continue logic, not scummy nested if.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;the logic should be if it is successful kill PID, the output should be = 0, that should not go to next loop.&lt;BR /&gt;&lt;BR /&gt;It doesn't go to the next kill -INT but does the next PID.</description>
      <pubDate>Tue, 15 Jan 2008 06:35:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126423#M315603</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-15T06:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126424#M315604</link>
      <description>thx dennis,&lt;BR /&gt;&lt;BR /&gt;for PID in $(&amp;lt; pid_file); do&lt;BR /&gt;   kill -0 $PID 2&amp;gt; /dev/null&lt;BR /&gt;   if [ $? -ne 0 ]; then&lt;BR /&gt;      echo "PID $PID is not alive"&lt;BR /&gt;      continue&lt;BR /&gt;   fi&lt;BR /&gt;   echo kill $PID&lt;BR /&gt;   false  # remove after script tested&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo kill -INT $PID&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo kill -QUIT $PID&lt;BR /&gt;   if [ $? -eq 0 ]; then continue; fi&lt;BR /&gt;   echo mailx -s "Problem killing process" root &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;Problem killing $PID.&lt;BR /&gt;EOF&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I tried the script , I hve edit the pid_file , some of pid are exist and some are non-exist , but when the script , it shows are pid is not alive .&lt;BR /&gt;&lt;BR /&gt;PID 58745 is not alive&lt;BR /&gt;PID 15645 is not alive&lt;BR /&gt;PID 87852 is not alive&lt;BR /&gt;PID 15645 is not alive&lt;BR /&gt;PID 14454 is not alive&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while PID 15645 is exist in my system , can advise what is wrong ? thx</description>
      <pubDate>Thu, 17 Jan 2008 09:38:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126424#M315604</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-17T09:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126425#M315605</link>
      <description>I tried &lt;BR /&gt;&lt;BR /&gt;kill -0 15645  , the result is "Operation not permitted" .&lt;BR /&gt;&lt;BR /&gt;thx</description>
      <pubDate>Thu, 17 Jan 2008 09:46:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126425#M315605</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-17T09:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126426#M315606</link>
      <description>&amp;gt;kill -0 15645, the result is "Operation not permitted"&lt;BR /&gt;&lt;BR /&gt;Something wrong here.  I don't get that on HP-UX.  You may get "permission denied".&lt;BR /&gt;And if these are the same, it means you need to be root to kill that process.</description>
      <pubDate>Fri, 18 Jan 2008 03:44:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126426#M315606</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-18T03:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126427#M315607</link>
      <description>thx dennis ,&lt;BR /&gt;&lt;BR /&gt;if use root to kill -0 , it works, I would like to further ask , if there are many process in the file pid_file , some are of process are alive , some are not alive , the script will still kill the process are alive ? &lt;BR /&gt;&lt;BR /&gt;thx</description>
      <pubDate>Fri, 18 Jan 2008 07:41:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126427#M315607</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-18T07:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126428#M315608</link>
      <description>&amp;gt;the script will still kill the process are alive?&lt;BR /&gt;&lt;BR /&gt;Yes.  But if your file has data from hours and days ago, you might kill the wrong process, because PIDs are eventually reused.&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Jan 2008 07:48:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126428#M315608</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-18T07:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126429#M315609</link>
      <description>thx Dennis ,&lt;BR /&gt;&lt;BR /&gt;Yes. But if your file has data from hours and days ago, you might kill the wrong process, because PIDs are eventually reused --&amp;gt; &lt;BR /&gt;&lt;BR /&gt;I will remove pid_file after it kill the process , the new pid_file will be generated if it is required to kill .&lt;BR /&gt;&lt;BR /&gt;I would like to confirm you whether the logic is :&lt;BR /&gt;it first read all pid in pid_file (kill -0) , it try to kill it by "kill" , if successful to kill , then do nothing , if unsuccessful to kill , then try kill -INT , if still not success , then try kill -QUIT , if still not success , then mailx , is the logic correct ? thx</description>
      <pubDate>Fri, 18 Jan 2008 08:32:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126429#M315609</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2008-01-18T08:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: user process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126430#M315610</link>
      <description>&amp;gt;I would like to confirm you whether the logic is:&lt;BR /&gt;&amp;gt;it first read all pid in pid_file (kill -0),&lt;BR /&gt;&lt;BR /&gt;It reads them all in the shell but it does them one by one.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;it try to kill it by "kill", if successful to kill, then do nothing, if unsuccessful to kill, then try kill -INT, if still not success, then try kill -QUIT, if still not success, then mailx, is the logic correct?&lt;BR /&gt;&lt;BR /&gt;Yes, if you remove those debugging "echo"s and one "false".</description>
      <pubDate>Fri, 18 Jan 2008 08:45:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process/m-p/4126430#M315610</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-18T08:45:26Z</dc:date>
    </item>
  </channel>
</rss>

