Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
For monitoring I would try connecting to it; check that it's work spool is not growing larger than X or something else that works for the specific application.

For keeping a daemon alive I usually use the following for that kind of thing. If the process really wants to exit it does so with exit code 10; otherwise it'll get started again.

#!/bin/sh # Keep a daemon running and running and running ... # # Normally starts a process in the background # unless "bg" is given as the second argument. trap '' 1 15 # ignore SIG HUP & TERM PATH=/usr/xpg4/bin:$PATH # Solaris compatibility if test `id -u` = 0 then su - foo -c "$0 $1" & exit fi if test "$1" != "-bg" then echo "$0 $$: Starting $* in background" $0 -bg "$@" & exit fi shift # remove the -bg PROGRAM=$1; shift # get and remove program name while true do echo "$0 $$: Starting $PROGRAM $@" $PROGRAM "$@" < /dev/null status=$? if test $status -eq 10 ; then msg="$PROGRAM $@ exited with status 10 - not restarted" logger -p 'local0.warning' "$msg" echo "$msg" exit 0 fi msg="$PROGRAM $@ exited with status $status - will restart (pa +rent=$$)" logger -p 'local0.warning' "$msg" echo "$msg" sleep 2 done
(replace foo with something else if you want to make sure you always start the program as a specific user).

 - ask

-- 
ask bjoern hansen, http://ask.netcetera.dk/   !try; do();

In reply to Re: Best way to ensure process is live by ask
in thread Best way to ensure process is live by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-20 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found