<?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: Monitor a process, then restart it if its down.... in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976651#M93256</link>
    <description>If this is a process that runs all the time, you could put an entry in "/etc/inittab". If you set the second parameter to "respawn", then init will re-launch the process if it terminates.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Tue, 02 May 2006 11:16:18 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2006-05-02T11:16:18Z</dc:date>
    <item>
      <title>Monitor a process, then restart it if its down....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976648#M93253</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have a particlar process that I want to monitor continously and that I want to restart if it stops.&lt;BR /&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 May 2006 11:02:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976648#M93253</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2006-05-02T11:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Monitor a process, then restart it if its down....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976649#M93254</link>
      <description>Perhaps a cron or at job that runs every minute, checks for the presence of said process and re-initiates it if absent?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Tue, 02 May 2006 11:08:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976649#M93254</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-05-02T11:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Monitor a process, then restart it if its down....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976650#M93255</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Lets use sendmail as an example.&lt;BR /&gt;&lt;BR /&gt;Script stubb&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;procname=sendmail&lt;BR /&gt;UNIX95=1&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;  sprocs=$(ps -C $procname)&lt;BR /&gt;  if [ $sprocs -eq 0 ]&lt;BR /&gt;  then&lt;BR /&gt;     /sbin/init.d/sendmail start&lt;BR /&gt;  fi&lt;BR /&gt;  sleep 1800&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This script stub(incomplete script) sees if sendmail is running. It does not use grep, which Bill Hassell says is a no-no.&lt;BR /&gt;&lt;BR /&gt;If the number of sendmail processes is 0 it restarts the daemon.&lt;BR /&gt;&lt;BR /&gt;What it needs is code if it can't restart the daemon. Obviously by changing it, you can monitor any daemon.&lt;BR /&gt;&lt;BR /&gt;Note, if you want to monitor oracle, its unfortuneatly quite possible for there to be a process and the database be hoplessly down. You need sql code to accurately monitor oracle.&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;</description>
      <pubDate>Tue, 02 May 2006 11:12:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976650#M93255</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-05-02T11:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Monitor a process, then restart it if its down....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976651#M93256</link>
      <description>If this is a process that runs all the time, you could put an entry in "/etc/inittab". If you set the second parameter to "respawn", then init will re-launch the process if it terminates.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 02 May 2006 11:16:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976651#M93256</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-05-02T11:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Monitor a process, then restart it if its down....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976652#M93257</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can put the process into /etc/inittab with respawn option. RTFM for inittab&lt;BR /&gt;HTH&lt;BR /&gt;</description>
      <pubDate>Tue, 02 May 2006 11:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976652#M93257</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2006-05-02T11:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Monitor a process, then restart it if its down....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976653#M93258</link>
      <description>Well we do it much like Steve's post.  But I actually start that monitoring script from cron every 15 minutes, then have that script check and see if a copy of itself is already running, if it is, it exits.  Otherwise, it proceeds to go into a loop and monitor the process that supposed to be running. &lt;BR /&gt;&lt;BR /&gt;This way, if the program dies, the monitor catches it.  If the monitor dies, it is relaunched via cron, and if both die, then the monitor launches, and in turn launches the monitored process.  &lt;BR /&gt;&lt;BR /&gt;If I may expand on/change Steve's example; here's the script to have run from cron.  Be aware that to make it run from cron, you may have put put in absolute paths for every command in the file (e.g. put in "/usr/bin/ps" instead of "ps").&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;                                                                                                                        &lt;BR /&gt;export CYCLE_TIME=1800&lt;BR /&gt;export PROCNAME=sendmail&lt;BR /&gt;                                                                                                                        &lt;BR /&gt;# Chk to see if monitor is already running&lt;BR /&gt;export MYPROG=`basename $0`&lt;BR /&gt;let PROGCOUNT=0&lt;BR /&gt;export PROGCOUNT&lt;BR /&gt;                                                                                                                        &lt;BR /&gt;UNIX95=1&lt;BR /&gt;PROGCOUNT=`ps -C ${MYPROG}| wc -l`&lt;BR /&gt;UNIX95=0&lt;BR /&gt;if [ $PROGCOUNT -gt 2 ]; then&lt;BR /&gt;   exit 0&lt;BR /&gt;fi&lt;BR /&gt;                                                                                                                        &lt;BR /&gt;# Monitor sendmail&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;                                                                                                                        &lt;BR /&gt;UNIX95=1&lt;BR /&gt;PROGCOUNT=`ps -C ${PROCNAME}|wc -l`&lt;BR /&gt;UNIX95=0&lt;BR /&gt;if [ $PROGCOUNT -lt 2 ]; then&lt;BR /&gt;/sbin/init.d/sendmail start&lt;BR /&gt;fi&lt;BR /&gt;                                                                                                                        &lt;BR /&gt;sleep $CYCLE_TIME&lt;BR /&gt;                                                                                                                        &lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 02 May 2006 12:33:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976653#M93258</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2006-05-02T12:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Monitor a process, then restart it if its down....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976654#M93259</link>
      <description>#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;export CYCLE_TIME=1800&lt;BR /&gt;export PROCNAME=sendmail&lt;BR /&gt;&lt;BR /&gt;# Chk to see if monitor is already running&lt;BR /&gt;export MYPROG=`basename $0`&lt;BR /&gt;let PROGCOUNT=0&lt;BR /&gt;export PROGCOUNT&lt;BR /&gt;&lt;BR /&gt;UNIX95=1&lt;BR /&gt;PROGCOUNT=`ps -C ${MYPROG}| wc -l`&lt;BR /&gt;UNIX95=0&lt;BR /&gt;if [ $PROGCOUNT -gt 2 ]; then&lt;BR /&gt;exit 0&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# Monitor sendmail&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;UNIX95=1&lt;BR /&gt;PROGCOUNT=`ps -C ${PROCNAME}|wc -l`&lt;BR /&gt;UNIX95=0&lt;BR /&gt;if [ $PROGCOUNT -lt 2 ]; then&lt;BR /&gt;/sbin/init.d/sendmail start&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;sleep $CYCLE_TIME&lt;BR /&gt;&lt;BR /&gt;done</description>
      <pubDate>Thu, 31 Jan 2008 16:18:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitor-a-process-then-restart-it-if-its-down/m-p/4976654#M93259</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2008-01-31T16:18:40Z</dc:date>
    </item>
  </channel>
</rss>

