<?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: check process in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630858#M237663</link>
    <description>or if I want the job run repeatedly , could suggest what can I do ? thx</description>
    <pubDate>Wed, 21 Sep 2005 02:05:11 GMT</pubDate>
    <dc:creator>hangyu</dc:creator>
    <dc:date>2005-09-21T02:05:11Z</dc:date>
    <item>
      <title>check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630850#M237655</link>
      <description>i have a script that read a file which contains process_id and time that he's&lt;BR /&gt;in and it lookes like this &lt;BR /&gt;0:30 54545&lt;BR /&gt;0:44 66788&lt;BR /&gt;0:50 23233&lt;BR /&gt;i need to read every line in the file and get the time and if the process is greater then 0:30 to kill the process id &lt;BR /&gt;the script looks like this &lt;BR /&gt;cat bbb | while read line &lt;BR /&gt;do &lt;BR /&gt;#kill -9 $i&lt;BR /&gt;done&lt;BR /&gt;i don't how to take of the hour , ask about it and kill the process&lt;BR /&gt;can you please help me and another question &lt;BR /&gt;did i do the loop ok did i need the pipe before the while</description>
      <pubDate>Wed, 21 Sep 2005 01:00:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630850#M237655</guid>
      <dc:creator>hangyu</dc:creator>
      <dc:date>2005-09-21T01:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630851#M237656</link>
      <description>I think you got the most of it.&lt;BR /&gt;&lt;BR /&gt;cat bbb | while read line&lt;BR /&gt;do&lt;BR /&gt;awk '{ if ($1&amp;lt;30) print kill -9 $2 }' | sh&lt;BR /&gt;done</description>
      <pubDate>Wed, 21 Sep 2005 01:10:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630851#M237656</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2005-09-21T01:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630852#M237657</link>
      <description>Use this:&lt;BR /&gt;&lt;BR /&gt;while read time pid&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;  sec=$(echo $time | cut -d":" -f1)&lt;BR /&gt; &lt;BR /&gt;  [[ $sec -gt 30 ]] &amp;amp;&amp;amp; kill -9 $pid&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 21 Sep 2005 01:16:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630852#M237657</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-21T01:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630853#M237658</link>
      <description>Use simply as,&lt;BR /&gt;&lt;BR /&gt;# awk '{ split($1,a,":"); if ( a[2] &amp;gt; 30 ) { print "kill -9 " $2 } }' &lt;FILENAME&gt; | ksh&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 21 Sep 2005 01:21:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630853#M237658</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-21T01:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630854#M237659</link>
      <description>With perl scripting, you don't need reverse shell execution as,&lt;BR /&gt;&lt;BR /&gt;perl -ne '($time,$pid)=split; @min=split(/:/,$time); kill 9,$pid if $min[1] &amp;gt; 30;' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 21 Sep 2005 01:27:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630854#M237659</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-21T01:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630855#M237660</link>
      <description>thx Muthukumar ,&lt;BR /&gt;&lt;BR /&gt;I use your script , but I tried to echo the $sec , all sec are "0" ( it should be 30 , 44 , 50 ) , so no one record greater than 30 , could suggest what is wrong ? thx&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while read time pid&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;sec=$(echo $time | cut -d":" -f1)&lt;BR /&gt;&lt;BR /&gt;[[ $sec -gt 30 ]] &amp;amp;&amp;amp; kill -9 $pid&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 21 Sep 2005 01:40:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630855#M237660</guid>
      <dc:creator>hangyu</dc:creator>
      <dc:date>2005-09-21T01:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630856#M237661</link>
      <description>I think it will be -f2</description>
      <pubDate>Wed, 21 Sep 2005 01:42:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630856#M237661</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2005-09-21T01:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630857#M237662</link>
      <description>thx replies ,&lt;BR /&gt;&lt;BR /&gt;it works now , it I want to script to check the process 3 times in very 1 minutes , the crontab job only can run 1 time in 1 minute , could suggest what can I do ? thx</description>
      <pubDate>Wed, 21 Sep 2005 02:02:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630857#M237662</guid>
      <dc:creator>hangyu</dc:creator>
      <dc:date>2005-09-21T02:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630858#M237663</link>
      <description>or if I want the job run repeatedly , could suggest what can I do ? thx</description>
      <pubDate>Wed, 21 Sep 2005 02:05:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630858#M237663</guid>
      <dc:creator>hangyu</dc:creator>
      <dc:date>2005-09-21T02:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630859#M237664</link>
      <description>while true&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;while read time pid&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;sec=$(echo $time | cut -d":" -f2)&lt;BR /&gt;&lt;BR /&gt;[[ $sec -gt 30 ]] &amp;amp;&amp;amp; kill -9 $pid&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;sleep 20&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;this will run in an infinite loop until you interrupt it.&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 21 Sep 2005 02:07:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630859#M237664</guid>
      <dc:creator>Orhan Biyiklioglu</dc:creator>
      <dc:date>2005-09-21T02:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630860#M237665</link>
      <description>thx reply ,&lt;BR /&gt;&lt;BR /&gt;the process can run repeatedly now , but if I add it to the cron , the process will run many many times , so I think it can't be add to the crontab , could suggest if not add to the crontab , how to make sure the job is keep on running ? thx.</description>
      <pubDate>Wed, 21 Sep 2005 03:14:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630860#M237665</guid>
      <dc:creator>hangyu</dc:creator>
      <dc:date>2005-09-21T03:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630861#M237666</link>
      <description>You can automate this script execution with crontab, at (schedulars) or with scripting running infintite.&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;# psck.ksh&lt;BR /&gt;while [ TRUE ]&lt;BR /&gt;while read time pid&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;ps -ef | grep -q $pid  |grep -v grep&lt;BR /&gt;if [[ $? -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt;  sec=$(echo $time | cut -d":" -f1)&lt;BR /&gt;  [[ $sec -gt 30 ]] &amp;amp;&amp;amp; kill -9 $pid&lt;BR /&gt;  echo "$pid is killed @ $(date)" &amp;gt;&amp;gt;/tmp/logfile&lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;done &amp;lt; &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;sleep 60&lt;BR /&gt;done&lt;BR /&gt;# end&lt;BR /&gt;&lt;BR /&gt;Run this script as,&lt;BR /&gt;&lt;BR /&gt;# chmod +x psck.ksh&lt;BR /&gt;# ./psck.ksh &amp;amp;&lt;BR /&gt;&lt;BR /&gt;# tail -f /tmp/logfile give details of process which killed.&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 21 Sep 2005 03:25:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630861#M237666</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-21T03:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630862#M237667</link>
      <description>&lt;BR /&gt;your explaination is very detail , but I am not too understand how to make sure the script is running in the system if not add it to the crontab ? thx</description>
      <pubDate>Wed, 21 Sep 2005 03:46:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630862#M237667</guid>
      <dc:creator>hangyu</dc:creator>
      <dc:date>2005-09-21T03:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630863#M237668</link>
      <description>You require a script to run 3 times every minute, Righto&lt;BR /&gt;&lt;BR /&gt;So make a loop in that script which runs 3 times.&lt;BR /&gt;Now add that script in cron scheduled for every minute.</description>
      <pubDate>Wed, 21 Sep 2005 05:34:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630863#M237668</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2005-09-21T05:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: check process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630864#M237669</link>
      <description>As mentioned, cron is limited to one minute resolution. So inside your script, either create a function that performs the kill and then sleep 20 (20 seconds) and repeat two more times, or just code the kill test 3 times with a sleep between each section.&lt;BR /&gt; &lt;BR /&gt;By the way: are you sure you want to use kill -9? It is a very bad command to use against programs, especially databases and other applications that use shared application resources. It is strongly recommended that you use kill -15, followed by a kill -1 (if kill -15 doesn't work) and finally kill -9 as a last resort.</description>
      <pubDate>Wed, 21 Sep 2005 08:04:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-process/m-p/3630864#M237669</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-09-21T08:04:04Z</dc:date>
    </item>
  </channel>
</rss>

