<?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: shell script for tracking processes in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719733#M100871</link>
    <description>Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;You could create a 'cron' task for the following.  Assume that you want to look for a process called "myproc" and email/page if it isn't running: &lt;BR /&gt;&lt;BR /&gt;# [ -z "`UNIX95= ps -C myproc -o pid= -o comm=`" ] &amp;amp;&amp;amp; mailx -s "myproc" is not running!" root &amp;lt; /dev/null&lt;BR /&gt;&lt;BR /&gt;You could replicate this for you second process too.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sun, 29 Jan 2006 19:59:38 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-01-29T19:59:38Z</dc:date>
    <item>
      <title>shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719732#M100870</link>
      <description>Dear Sirs,&lt;BR /&gt;&lt;BR /&gt;We are running an application on hpux11i and it runs 2 processes.&lt;BR /&gt;&lt;BR /&gt;I want to know the shell script which can send me an email if the processes are stopped running. &lt;BR /&gt;&lt;BR /&gt;I am not a seasoned shell scriptor, so your help is appriable.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shiv &lt;BR /&gt;</description>
      <pubDate>Sun, 29 Jan 2006 19:10:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719732#M100870</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-01-29T19:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719733#M100871</link>
      <description>Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;You could create a 'cron' task for the following.  Assume that you want to look for a process called "myproc" and email/page if it isn't running: &lt;BR /&gt;&lt;BR /&gt;# [ -z "`UNIX95= ps -C myproc -o pid= -o comm=`" ] &amp;amp;&amp;amp; mailx -s "myproc" is not running!" root &amp;lt; /dev/null&lt;BR /&gt;&lt;BR /&gt;You could replicate this for you second process too.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 29 Jan 2006 19:59:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719733#M100871</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-01-29T19:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719734#M100872</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;for critical processes, you can also include the coding for the processes to restart also.&lt;BR /&gt;&lt;BR /&gt;of course, you should identified all possible scenarios that can cause your processes to stop..&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Sun, 29 Jan 2006 23:41:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719734#M100872</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2006-01-29T23:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719735#M100873</link>
      <description>Hi Shiv, &lt;BR /&gt;&lt;BR /&gt;You can just use ps -ae |grep -i "process_name" and if [ $? &amp;gt;0 ]  mailx -s "Process_name not running" &lt;USER&gt; &lt;BR /&gt;&lt;BR /&gt;-Arun&lt;/USER&gt;</description>
      <pubDate>Sun, 29 Jan 2006 23:52:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719735#M100873</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-01-29T23:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719736#M100874</link>
      <description>Do you want to run it in continous manner or only one time?&lt;BR /&gt;&lt;BR /&gt;One time:&lt;BR /&gt;&lt;BR /&gt;ps -ef | grep -i &lt;PROCESS name=""&gt; | mailx -s "Process Info" ID&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu&lt;BR /&gt;&lt;/PROCESS&gt;</description>
      <pubDate>Mon, 30 Jan 2006 01:01:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719736#M100874</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-01-30T01:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719737#M100875</link>
      <description>To use for all process requirement:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;PROCESS_NAME=&lt;BR /&gt;SLEEP_TIME=60 # 1 minute&lt;BR /&gt;&lt;BR /&gt;while [[ 1 ]]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt; ps -ef | grep -qi "${PROCESS_NAME}" | mailx -s "Process @ $(date)" ID&lt;BR /&gt;  &lt;BR /&gt; sleep ${SLEEP_TIME}&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# END&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Jan 2006 01:03:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719737#M100875</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-01-30T01:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719738#M100876</link>
      <description>Hi Shiv,&lt;BR /&gt;something like this&lt;BR /&gt;PROCESS_COUNT=$(ps -fu &amp;lt;script user&amp;gt; | grep &amp;lt;script_name&amp;gt; | grep -v grep)&lt;BR /&gt;case $PROCESS_COUNT in&lt;BR /&gt;   0) TITLE=&lt;WHAT you="" want=""&gt;&lt;BR /&gt;      echo "ERR: &amp;lt;script_name is not running"|mailx -s $TITLE &lt;YOUR email="" address=""&gt;&lt;BR /&gt;      ;;&lt;BR /&gt;   1) #OK&lt;BR /&gt;      ;;&lt;BR /&gt;   *) TITLE=&lt;WAHT you="" want=""&gt;&lt;BR /&gt;      echo "ERR: more than 1 process is running"|mailx -s $TITLE &lt;YOUR email="" address=""&gt;&lt;BR /&gt;      ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art&lt;BR /&gt;&lt;/YOUR&gt;&lt;/WAHT&gt;&lt;/YOUR&gt;&lt;/WHAT&gt;</description>
      <pubDate>Tue, 31 Jan 2006 04:24:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719738#M100876</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-01-31T04:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719739#M100877</link>
      <description>James' script is the preferred method as it does not use grep to find a process. grep and ps can make a lot of mistakes since grep does not limit it's comparison to a specific field.&lt;BR /&gt; &lt;BR /&gt;However, all scripts that monitor the system to provide notifications will cause big email problems if they do not stop or slow down once the notification has been sent. You can put James' 1-liner into a loop that runs until a notification is made:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -u&lt;BR /&gt;export PATH=/usr/bin&lt;BR /&gt;# $1 is the process to monitor&lt;BR /&gt;if [ $# -lt 1 ]&lt;BR /&gt;then&lt;BR /&gt;echo "need MYPROC"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;MYPROC=$1&lt;BR /&gt;SYSADM=root # replace root with another email addr&lt;BR /&gt;MONSECS=30&lt;BR /&gt;RETRYSECS=3600&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;while :&lt;BR /&gt;do&lt;BR /&gt;MYSTATUS="$(UNIX95= $MYPROC -o pid= -o comm=)"&lt;BR /&gt;if [ -z "$MYPROC" ]&lt;BR /&gt;then&lt;BR /&gt; mailx -s "$MYPROC is not running!" $SYSADM&lt;BR /&gt; sleep $RETRYSECS&lt;BR /&gt;fi&lt;BR /&gt;sleep $MONSECS&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Now start the script in the background and it will run forever, but will provide the email warning once (within 30 seconds) of the failure, and then repeat the message every hour until the process is fixed.</description>
      <pubDate>Tue, 31 Jan 2006 08:08:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719739#M100877</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-01-31T08:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719740#M100878</link>
      <description>Whoops, some text is missing on the MYSTATUS line. It should read:&lt;BR /&gt; &lt;BR /&gt;MYSTATUS="$(UNIX95= ps -C $MYPROC -o pid= -o comm=)"</description>
      <pubDate>Tue, 31 Jan 2006 08:11:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719740#M100878</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-01-31T08:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719741#M100879</link>
      <description>Hello, &lt;BR /&gt;&lt;BR /&gt;I am also interesting in this.  But i find that $MYSTATUS is always null.&lt;BR /&gt;&lt;BR /&gt;What might i be doing wrong?&lt;BR /&gt;&lt;BR /&gt;I presume the script is supposed to be "-z $MYSTATUS" rather than $MYPROC.&lt;BR /&gt;&lt;BR /&gt;I am aware of UNIX95 but ps -C.... is always null... :-(&lt;BR /&gt;&lt;BR /&gt;this would be most useful!</description>
      <pubDate>Mon, 06 Feb 2006 08:49:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719741#M100879</guid>
      <dc:creator>Tom Satinet</dc:creator>
      <dc:date>2006-02-06T08:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719742#M100880</link>
      <description>The -C option provides an exact process name match. So if you were looking for /usr/bin/vi, the command would be:&lt;BR /&gt; &lt;BR /&gt;UNIX95= ps -f -C vi&lt;BR /&gt; &lt;BR /&gt;and to store the results of the ps search:&lt;BR /&gt; &lt;BR /&gt;MYSTATUS=$(UNIX95= ps -f -C vi)&lt;BR /&gt;echo $MYSTATUS&lt;BR /&gt; &lt;BR /&gt;Be sure you do not put a pathname (ie, -C /usr/bin/vi) because that is not the process name. The process name is just the last part of a pathname.</description>
      <pubDate>Mon, 06 Feb 2006 20:03:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719742#M100880</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-02-06T20:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719743#M100881</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;check it out also&lt;BR /&gt;&lt;BR /&gt;# ps -efx | grep &lt;PROCNAME&gt;&lt;BR /&gt;&lt;BR /&gt;to see all parameters of a process running,&lt;BR /&gt;&lt;BR /&gt;very useful with java processes.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pablo&lt;/PROCNAME&gt;</description>
      <pubDate>Tue, 07 Feb 2006 02:59:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719743#M100881</guid>
      <dc:creator>paolo barila</dc:creator>
      <dc:date>2006-02-07T02:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719744#M100882</link>
      <description>Shiv,&lt;BR /&gt;&lt;BR /&gt;I agree with Bill. JRF's script is the most elegant and efficient because it does it all on one line.&lt;BR /&gt;&lt;BR /&gt;Note: &lt;BR /&gt;Do not set the UNIX95 variable by default in /etc/profile, .profile or other profiles, unless you create a special user for this.&lt;BR /&gt;&lt;BR /&gt;A VERY common gotcha is setting this variable by default. It interferes with SD/UX when you sh a patch depot, it triggers checksum failures.&lt;BR /&gt;&lt;BR /&gt;I will admit that I fell victim to this very mistake some years ago.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 07 Feb 2006 04:05:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719744#M100882</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-02-07T04:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for tracking processes</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719745#M100883</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This is great. I have got this working now.  We have a stupid electronic invoicing system that send out emails. but it dies if it looses connection to the smtp server even for a second. don't ask why it can't wait..... p poor code....&lt;BR /&gt;&lt;BR /&gt;anyway, I think i will run this in a start up script and monitor the process.  Thanks for the warning on UNIX95. i think i will just run this as root, but set the variable in the script.&lt;BR /&gt;&lt;BR /&gt;many thanks:-D</description>
      <pubDate>Tue, 07 Feb 2006 04:12:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-for-tracking-processes/m-p/3719745#M100883</guid>
      <dc:creator>Tom Satinet</dc:creator>
      <dc:date>2006-02-07T04:12:30Z</dc:date>
    </item>
  </channel>
</rss>

