how to run a program as a daemon

Chuck Swiger cswiger at mac.com
Wed Sep 3 12:57:01 PDT 2003


David Banning wrote:
> I am running tmda-ofmipd for my smtp server and occasionally
> it dies. I wonder how I could set it up to run so that if it
> dies for some reason, it will start up again. Right now, it 
> starts in my rc.local like so;
> 
> /usr/local/bin/tmda-ofmipd  -R imap://localhost -u tofmipd

Look at DJB's daemontools, perhaps.  But the general idea is that you have a 
monitor script which looks like:

#! /bin/sh

while : ; do
    /usr/local/bin/tmda-ofmipd  -R imap://localhost -u tofmipd
    echo "TMDA daemon died!  Restarting in 5 seconds..."
    sleep 5
done

-- 
-Chuck




More information about the freebsd-questions mailing list