-1

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

Nitish
  • 103
  • 4
  • Do you have any ideas yourself ? – Lawrence Jan 07 '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 08 '14 at 09:32

1 Answers1

1

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
myprocess:2345:respawn:/bin/myprocess

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

Boogy
  • 556
  • 4
  • 6
  • 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 08 '14 at 09:20