This question already has an answer here:

An interviewer asked me this question in an interview.

He asked, suppose a service xyz stops due to any reason and you want it running all the time, what will you do so that it will start automatically

marked as duplicate by mpy, Tog, JdeBP, Heptite, Kevin Panko Jan 8 '14 at 3:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Jan 7 '14 at 12:31

This question came from our site for professional and enthusiast programmers.

  • Do you have any ideas yourself ? – Lawrence Jan 7 '14 at 12:35
  • The possible solution that I thought was, there might be some command similar to chkconfig or to add an entry of that process in some file though preferred to say no rather than to bluff. – Nitish Jan 8 '14 at 9:32

I don't want to be mean but a simple google search will give you a lot of options to do this. Here is one I found:

The easiest way would be to add it to /etc/inittab, which is designed to do this sort of thing:

respawn If the process does not exist, start the process. Do not wait for its termination (continue scanning the /etc/inittab file). Restart the process when it dies. If the process exists, do nothing and continue scanning the /etc/inittab file.

For example, you could do this:

# Run my stuff

Link: How to automatically restart a linux background process if it fails?

  • Thanks for the reply. I did google search but I guess I dint framed the question correctly and all I got is how to use service, chkconfig and systemctl commands – Nitish Jan 8 '14 at 9:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.