<?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: Script-Check if process running, if not start it up in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490183#M19376</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If you are involving the use of grep on a ps output, please remember to add a "| grep -v grep". &lt;BR /&gt;&lt;BR /&gt;This is because grep itself is a process displayed with ps. If you ps -fae|grep PROC_NAME, other than the PROC_NAME process being reflected, "grep PROC_NAME" process will also be reflected. By adding "| grep -v grep" to form a "ps -fae|grep PROC_NAME|grep -v grep", you effectively filter off the display of the grep process.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;</description>
    <pubDate>Wed, 07 Feb 2001 03:01:59 GMT</pubDate>
    <dc:creator>Steven Sim Kok Leong</dc:creator>
    <dc:date>2001-02-07T03:01:59Z</dc:date>
    <item>
      <title>Script-Check if process running, if not start it up</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490178#M19371</link>
      <description>Can anyone recommend a script that will check to see if a process is running and if it isn't attempt to start it back up?&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;&lt;BR /&gt;Greg</description>
      <pubDate>Tue, 06 Feb 2001 12:26:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490178#M19371</guid>
      <dc:creator>Greg Hale</dc:creator>
      <dc:date>2001-02-06T12:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script-Check if process running, if not start it up</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490179#M19372</link>
      <description>Hi,&lt;BR /&gt;I would write a script to be run by cron like:&lt;BR /&gt;&lt;BR /&gt;#script&lt;BR /&gt;PROC=`ps -ef? grep -c ?your_proc?`&lt;BR /&gt;&lt;BR /&gt;case $PROC in&lt;BR /&gt;1) #Process OK&lt;BR /&gt;   ;;&lt;BR /&gt;0) # Not there so start it&lt;BR /&gt;   /sbin/init.d/ Sxxx&lt;OUR_PROC start=""&gt;&lt;/OUR_PROC&gt;esac&lt;BR /&gt;#exit&lt;BR /&gt;&lt;BR /&gt;Good luck&lt;BR /&gt;All the best&lt;BR /&gt;Victor</description>
      <pubDate>Tue, 06 Feb 2001 12:37:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490179#M19372</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2001-02-06T12:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Script-Check if process running, if not start it up</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490180#M19373</link>
      <description>Hi !&lt;BR /&gt;&lt;BR /&gt;Use ps -e instead of ps -ef and &lt;BR /&gt;grep ' proc_name$'.&lt;BR /&gt;&lt;BR /&gt;So&lt;BR /&gt;if [ $(ps -e | grep ' proc_name$' | wc -l) -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;    exit # process run&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;regards, Saa&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Feb 2001 12:48:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490180#M19373</guid>
      <dc:creator>Sandor Horvath_2</dc:creator>
      <dc:date>2001-02-06T12:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script-Check if process running, if not start it up</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490181#M19374</link>
      <description>Hi Greg:&lt;BR /&gt;&lt;BR /&gt;Here's a hypothetical script that monitors a process that it spawns, restarting the process as soon as it dies.  It gives you another example to think about:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;function WHAT&lt;BR /&gt;{&lt;BR /&gt;  sleep 30 &amp;amp; #...run in background...&lt;BR /&gt;}&lt;BR /&gt;while true   #...forever...&lt;BR /&gt;do&lt;BR /&gt;  WHAT&lt;BR /&gt;  WHO=$!&lt;BR /&gt;  echo "pid_${WHO} started"&lt;BR /&gt;  while true&lt;BR /&gt;  do&lt;BR /&gt;    kill -0 $WHO 2&amp;gt; /dev/null   #...check for the pid...&lt;BR /&gt;    if [ $? -ne 0 ]&lt;BR /&gt;    then&lt;BR /&gt;      echo "\npid_${WHO} died"&lt;BR /&gt;      break                     #...exit inner loop ...&lt;BR /&gt;    else                        #...it's still alive...&lt;BR /&gt;      sleep 1&lt;BR /&gt;      echo ".\c"&lt;BR /&gt;    fi&lt;BR /&gt;  done&lt;BR /&gt;done&lt;BR /&gt;#_end&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 06 Feb 2001 14:26:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490181#M19374</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-02-06T14:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Script-Check if process running, if not start it up</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490182#M19375</link>
      <description>There are lots of ways to solve this problem.  One of them is to use the init process.  Anything started from inittab with a "respawn" flag is started at the specified run level, monitored, and restarted if it dies.&lt;BR /&gt;&lt;BR /&gt;Why reinvent the wheel?</description>
      <pubDate>Tue, 06 Feb 2001 15:47:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490182#M19375</guid>
      <dc:creator>Alan Riggs</dc:creator>
      <dc:date>2001-02-06T15:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Script-Check if process running, if not start it up</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490183#M19376</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If you are involving the use of grep on a ps output, please remember to add a "| grep -v grep". &lt;BR /&gt;&lt;BR /&gt;This is because grep itself is a process displayed with ps. If you ps -fae|grep PROC_NAME, other than the PROC_NAME process being reflected, "grep PROC_NAME" process will also be reflected. By adding "| grep -v grep" to form a "ps -fae|grep PROC_NAME|grep -v grep", you effectively filter off the display of the grep process.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;</description>
      <pubDate>Wed, 07 Feb 2001 03:01:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-check-if-process-running-if-not-start-it-up/m-p/2490183#M19376</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2001-02-07T03:01:59Z</dc:date>
    </item>
  </channel>
</rss>

