-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

2
  • Do you have any ideas yourself ?
    – Lawrence
    Jan 7, 2014 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, 2014 at 9:32

1 Answer 1

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?

1
  • 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, 2014 at 9:20

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