Cal McPherson <[EMAIL PROTECTED]> writes:

> A method I can think of is writing a shell script to su into my user and run
> the daemon:
>
> #!/bin/sh
> #
> # mydaemon.sh
> su -c "mydaemond" myuser
>
> If I add the the following entry into intitab:
>
> 100:5:respawn:/usr/local/bin/mydaemon.sh

> I am testing this scenario with a daemon which crashes almost instantly. It
> is being restarted very quickly 10 times in succession, then there is a
> larger gap until the next 10 respawns. Is there a better way of doing this?
> TAI.

If you're just testing, or even in production, you could use a shell
script, ie

#!/bin/sh

while true; do
      mydaemon
      sleep 5
done

I've used both inittabs and shell scripts to do this. There's also
daemons designed to keep other daemon running, two examples which I've
never used are monit and launchtool.

One thing I found annoying with using inittab is stopping the daemon,
it's a bit of a pain, editing inittab, reload init, etc. I do
something like:

while true; do
      while [ -f /tmp/dont-restart-mydaemon ]; do
            sleep 5
      done
      mydaemon
      sleep 5
done

If I want to stop the daemon for a while, 
touch /tmp/dont-restart-mydaemon; killall mydaemon
rm /tmp/dont-restart-mydaemon to restart it.
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to