LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   automatic reload stopped daemon (https://www.linuxquestions.org/questions/linux-networking-3/automatic-reload-stopped-daemon-18024/)

phliver 04-08-2002 01:18 PM

automatic reload stopped daemon
 
i have a dns2go daemon that i need to have running all the time. once in awhile it quits. how would i set it up to atomatically start everytime it stops? somebody once told me to write a script and put it in cron to detect if its running or not but i KNOW there is an easier way. mabie in the startup script?

Mik 04-09-2002 03:22 AM

You could run it from the mother of all processes and let it respawn when it dies. Edit the file /etc/inittab and add a line for your process. Something like:

myapp:2345:respawn:/usr/bin/myapp

First field is an id name,
second field is the runlevels (in this case 2 - 5),
third field tells it to respawn it when it dies,
fourth field is the command used to run the process.

You have to make sure you have everything configured properly for that app. Because if it gets an error and dies right away it will try to respawn it. Which can result in the error respawning too fast. Often this will prevent your system from booting. So depending on how important the daemon is, it might be better to use a cron script to make sure it's still running.

hanzerik 04-09-2002 07:09 AM

try this:
crontab -e
add this line:

0 * * * * cd <dir/to/dns2go>; ./dns2go -nice 19 > /dev/null 2> /dev/null

Where <dir/to/dns2go> is the directory where the dns2go executable is installed.
This cron job will attempt to start the program at the top of every hour.
If it is already running, the next invocation will do nothing.
If the program is not running, it will be started.


It works for the setiathome client. Had setiathome running for about 6months straight, before the NIC went out.

phliver 04-09-2002 10:07 AM

thanks for your help guys, the inittab sounds like what i was looking for, but at least i was pointed in the right direction, so i can do more research on both cron and inittab.


All times are GMT -5. The time now is 05:04 PM.