<?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 to restart service automatically in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997026#M423655</link>
    <description>Dear all,&lt;BR /&gt;Thank you for your help :)&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;Cahyo</description>
    <pubDate>Tue, 15 Aug 2006 04:04:52 GMT</pubDate>
    <dc:creator>Cahyo Tri Nugroho</dc:creator>
    <dc:date>2006-08-15T04:04:52Z</dc:date>
    <item>
      <title>Shell script to restart service automatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997020#M423649</link>
      <description>Dear,&lt;BR /&gt;&lt;BR /&gt;Is there anybody have shell script that can check running services and automatically start the service if it goes down?&lt;BR /&gt;TIA.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Cahyo</description>
      <pubDate>Sun, 13 Aug 2006 22:42:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997020#M423649</guid>
      <dc:creator>Cahyo Tri Nugroho</dc:creator>
      <dc:date>2006-08-13T22:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to restart service automatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997021#M423650</link>
      <description>Shalom Cahyo,&lt;BR /&gt;&lt;BR /&gt;Here is an example&lt;BR /&gt;&lt;BR /&gt;export UNIX95=1&lt;BR /&gt;smproc=$(ps -C sendmail | wc -l)&lt;BR /&gt;&lt;BR /&gt;if [ $smproc -le 0 ]&lt;BR /&gt;then&lt;BR /&gt;    /sbin/init.d/sendmail start&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;You have to write it yourself for the service you wish to monitor.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Mon, 14 Aug 2006 01:21:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997021#M423650</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-08-14T01:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to restart service automatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997022#M423651</link>
      <description>Cahyo,&lt;BR /&gt;assuming you want to not test once, schedule Steven's script via cron to run at specified intervals. See man cron and man crontab&lt;BR /&gt;&lt;BR /&gt;And/or see Steven's loop solution at:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=1024003" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=1024003&lt;/A&gt;</description>
      <pubDate>Mon, 14 Aug 2006 03:20:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997022#M423651</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-08-14T03:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to restart service automatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997023#M423652</link>
      <description>Steven,&lt;BR /&gt;&lt;BR /&gt;I believe "if [ $smproc -le 0 ]" should be "if [ $smproc -le 1 ]", as 'ps' also returns column headings:&lt;BR /&gt;&lt;BR /&gt;# UNIX95= ps -C foo123xyz | wc -l&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;Cahyo,&lt;BR /&gt;&lt;BR /&gt;Another (less elegant) option:&lt;BR /&gt;&lt;BR /&gt;# while :; do sleep 10; /sbin/init.d/your_daemon start; done &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt;&lt;BR /&gt;'nohup' will allow it to persist after your session terminates.&lt;BR /&gt;&lt;BR /&gt;PCS&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 07:51:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997023#M423652</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-08-14T07:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to restart service automatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997024#M423653</link>
      <description>&lt;!--!*#--&gt;hi cahyo,&lt;BR /&gt;&lt;BR /&gt;one simple and clean solution would be to use cron to run the check script at regular interval.&lt;BR /&gt;&lt;BR /&gt;e.g. Cron entry that will check your service every 15 minutes.&lt;BR /&gt;&lt;BR /&gt;15    *  *  *   *  /users/scripts/check_service.sh 1&amp;gt;/users/scripts/logfiles/output-checkscript.crn 2&amp;gt;/users/scripts/logfiles/error-checkscript.crn&lt;BR /&gt;#&lt;BR /&gt;#*******************************************************************************&lt;BR /&gt;# min|hour |day  |month|day  |script&lt;BR /&gt;#    |     |of mo|     |of wk|&lt;BR /&gt;#----|-----|-----|-----|-----|--------------------------------------------------&lt;BR /&gt;#*******************************************************************************&lt;BR /&gt;#*******************************************************************************&lt;BR /&gt;# END OF TABLE           day0-&amp;gt;Sunday  day6-&amp;gt;Saturday&lt;BR /&gt;#*******************************************************************************&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Mon, 14 Aug 2006 08:01:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997024#M423653</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2006-08-14T08:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to restart service automatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997025#M423654</link>
      <description>A couple of things about using ps to restart a specific process:&lt;BR /&gt; &lt;BR /&gt;&amp;gt; export UNIX95=1&lt;BR /&gt;&amp;gt; smproc=$(ps -C sendmail | wc -l)&lt;BR /&gt;&amp;gt; if [ $smproc -le 0 ]&lt;BR /&gt;&amp;gt; then&lt;BR /&gt;&amp;gt; /sbin/init.d/sendmail start&lt;BR /&gt;&amp;gt; fi&lt;BR /&gt; &lt;BR /&gt;It's best never to export the UNIX95 variable, even in a script. UNIX95 enables more options in ps but also affects several other commands and libraries. Use UNIX95 as a temporary variable on the command line as in:&lt;BR /&gt; &lt;BR /&gt;UNIX95=1 ps -C sendmail&lt;BR /&gt; &lt;BR /&gt;Now to eliminate ps headers, use the -o option as in:&lt;BR /&gt; &lt;BR /&gt;UNIX95=1 ps -C sendmail -o pid= -o args=&lt;BR /&gt; &lt;BR /&gt;This eliminates the header line and makes the count correct. So the script would look like this:&lt;BR /&gt; &lt;BR /&gt;MYPROC=sendmail&lt;BR /&gt;COUNT=$(UNIX95=1 ps -C $MYPROC -o pid= -o args= | wc -l)&lt;BR /&gt;if [ $COUNT -lt 1 ]&lt;BR /&gt;then&lt;BR /&gt;/sbin/init.d/$MYPROC start&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;Now the above script is only an example. For instance, if a process is unexpectedly not running, there may be some cleanup tasks that must be accomplished first. With any automated 'fix' for a broken program, you need to investigate why the process is stopping unexpectedly and eliminate the problem rather than kickstarting it from cron.</description>
      <pubDate>Mon, 14 Aug 2006 08:33:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997025#M423654</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-08-14T08:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to restart service automatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997026#M423655</link>
      <description>Dear all,&lt;BR /&gt;Thank you for your help :)&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;Cahyo</description>
      <pubDate>Tue, 15 Aug 2006 04:04:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-restart-service-automatically/m-p/4997026#M423655</guid>
      <dc:creator>Cahyo Tri Nugroho</dc:creator>
      <dc:date>2006-08-15T04:04:52Z</dc:date>
    </item>
  </channel>
</rss>

