Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have an certain daemon that sometimes shutdown it self without any reason!
Can I make certain thing to automatically restart this application after it shutdown?
If yes, then how?
u must write a shell script that monitor your specified service
or deamon either it is running or not if it is stopped then restart it
again and put this script in crown job run it every after 1 minute
may i know weather can have have the solution for what have you discuss long time ago regarding the script for the named service to be automatic restart when is fail.
If you want a deamon to restart automatically whenever it dies, you can get the use of our best friend, INIT.
We can do this by adding an entry in /etc/inittab
Just like how your login prompt respawns everytime you're logged out and ended the session, we can use the respawn directive to respawn any daemon that dies.
Use and entry as such
# in /etc/inittab
c1:345:respawn:/path/to/my/daemon
Note: second field denotes which run-level you want the daemon to be active in.
c1, or the first field to be exact, is for ID. Just a unique identifier for that entry. Not associated to any TTY, unless you are running a Login Process, for which u put in the related TTY (required for login accounting).
From man inittab
Quote:
id is a unique sequence of 1-4 characters which identifies an entry in inittab (for versions of sysvinit compiled with libraries < 5.2.18 or a.out libraries the limit is 2 characters).
Oh,.. and since named is a startup script, you'll need to follow up with "start":
/etc/init.d/named start
respawning thru INIT is usually used for daemons that are not called thru the start-stop daemon (like some installations of Oracle), so i'm not too sure if it will work for named, but you could give it a try i guess.
Perhaps a more permanent solution would be to figure out why your named shuts down for no particular reason, and fix that instead?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.