<?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 mode in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464992#M210744</link>
    <description>thx reply,&lt;BR /&gt;&lt;BR /&gt;I modified the script to as below , but it seems not kill any user , could suggest what is wrong ? thx&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;set -x&lt;BR /&gt;for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print &lt;BR /&gt;($1*60)+$2":"$3 }'`&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;time=`echo $user | awk -F ":" '{ print $1 }'`&lt;BR /&gt;pid=`echo $user | awk -F ":" '{ print $2 }'`&lt;BR /&gt;state=`ps -el |grep $pid | awk '{print $2}'`&lt;BR /&gt;if [[ $state == S ]] #compare string&lt;BR /&gt;then&lt;BR /&gt;if [[ $time -gt 180 ]]&lt;BR /&gt;then&lt;BR /&gt;kill -1  $pid  2 &amp;gt;&amp;gt; /dev/null&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;done 2&amp;gt;&amp;gt; /dev/null&lt;BR /&gt;</description>
    <pubDate>Tue, 18 Jan 2005 00:03:22 GMT</pubDate>
    <dc:creator>peterchu</dc:creator>
    <dc:date>2005-01-18T00:03:22Z</dc:date>
    <item>
      <title>User process mode</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464990#M210742</link>
      <description>I have the below script to kill the user who idle for 180 minutes, it work fine , if I want to have one more checking - if the process is in "Runing" mode not in "Sleep" mode , then the process will not be killed ( that mean only kill the "Sleep" mode process ) could suggest how can I modify the script ? thx.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;set -x&lt;BR /&gt;for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print ($1*60)+$2":"$3 }'`&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;time=`echo $user | awk -F ":" '{ print $1 }'`&lt;BR /&gt;pid=`echo $user | awk -F ":" '{ print $2 }'`&lt;BR /&gt;&lt;BR /&gt;if [[ $time -gt 180 ]]&lt;BR /&gt;then&lt;BR /&gt;kill -1  $pid  2 &amp;gt;&amp;gt; /dev/null&lt;BR /&gt;fi</description>
      <pubDate>Mon, 17 Jan 2005 21:50:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464990#M210742</guid>
      <dc:creator>peterchu</dc:creator>
      <dc:date>2005-01-17T21:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: User process mode</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464991#M210743</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can add to your script :&lt;BR /&gt;&lt;BR /&gt;state=`ps -el |grep $pid | awk '{print $2}'&lt;BR /&gt;if [[ $state == S ]] #compare string &lt;BR /&gt;then&lt;BR /&gt;&lt;BR /&gt;kill...&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;HMT&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Jan 2005 22:25:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464991#M210743</guid>
      <dc:creator>Hoang Minh Tuan</dc:creator>
      <dc:date>2005-01-17T22:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: User process mode</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464992#M210744</link>
      <description>thx reply,&lt;BR /&gt;&lt;BR /&gt;I modified the script to as below , but it seems not kill any user , could suggest what is wrong ? thx&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;set -x&lt;BR /&gt;for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print &lt;BR /&gt;($1*60)+$2":"$3 }'`&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;time=`echo $user | awk -F ":" '{ print $1 }'`&lt;BR /&gt;pid=`echo $user | awk -F ":" '{ print $2 }'`&lt;BR /&gt;state=`ps -el |grep $pid | awk '{print $2}'`&lt;BR /&gt;if [[ $state == S ]] #compare string&lt;BR /&gt;then&lt;BR /&gt;if [[ $time -gt 180 ]]&lt;BR /&gt;then&lt;BR /&gt;kill -1  $pid  2 &amp;gt;&amp;gt; /dev/null&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;done 2&amp;gt;&amp;gt; /dev/null&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jan 2005 00:03:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464992#M210744</guid>
      <dc:creator>peterchu</dc:creator>
      <dc:date>2005-01-18T00:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: User process mode</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464993#M210745</link>
      <description>Could you show me the log file (&amp;gt;&amp;gt; /tmp/log, not null).&lt;BR /&gt;you change to ps -efl (not ps -el)&lt;BR /&gt;&lt;BR /&gt;HMT</description>
      <pubDate>Tue, 18 Jan 2005 02:10:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464993#M210745</guid>
      <dc:creator>Hoang Minh Tuan</dc:creator>
      <dc:date>2005-01-18T02:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: User process mode</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464994#M210746</link>
      <description>Sorry, I give you the incorrect script. I was confused about comparation string in shell script and because my internet be disconnected so I post this script not sooner for you. This is the correct &lt;BR /&gt;&lt;BR /&gt;set -x&lt;BR /&gt;for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print &lt;BR /&gt;($1*60)+$2":"$3 }'`&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt; time=`echo $user | awk -F ":" '{ print $1 }'`&lt;BR /&gt; pid=`echo $user | awk -F ":" '{print $2}'`&lt;BR /&gt; state=`ps -el |grep $pid | awk '{print $2" "$4}'| grep $pid | awk '{print $1}'` #catch pid state&lt;BR /&gt;  &lt;BR /&gt;  if [ $state=S ]   #compare string&lt;BR /&gt;  then&lt;BR /&gt;   if [[ $time -gt 180 ]]&lt;BR /&gt;   then&lt;BR /&gt;    kill -1 $pid  &amp;gt;&amp;gt; /dev/null&lt;BR /&gt;   fi&lt;BR /&gt;  fi &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;HMT</description>
      <pubDate>Tue, 18 Jan 2005 06:34:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464994#M210746</guid>
      <dc:creator>Hoang Minh Tuan</dc:creator>
      <dc:date>2005-01-18T06:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: User process mode</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464995#M210747</link>
      <description>Peter,&lt;BR /&gt;&lt;BR /&gt;Keep in mind that you are looking only at a snapshot of the process table when you do a 'ps'.  All process sleep while waiting for their CPU time-slice, so the chances of your script finding a user's sleeping process is quite high.  But since you are also defining the idle time limit at 180 minutes, the state  of the process is somewhat of a moot point.&lt;BR /&gt;&lt;BR /&gt;Just my 2cts worth,&lt;BR /&gt;Mark</description>
      <pubDate>Wed, 19 Jan 2005 10:24:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-process-mode/m-p/3464995#M210747</guid>
      <dc:creator>Mark Ellzey</dc:creator>
      <dc:date>2005-01-19T10:24:38Z</dc:date>
    </item>
  </channel>
</rss>

