1

Scenario:
I have a process running on linux which is started in the background by a script hooked up at /etc/init.d/ called as MyApp which is just a shell script without the .sh. Following is my init.d script script

#!/bin/sh

PARAM=$1

case ${PARAM} in
    start)
        MyApp &
        ;;
    stop)
        killall -9 MyApp
        ;;
    *)
        echo "Usage: $0 {start|stop}" >&2
        exit 1
        ;;
esac

As you can see it starts MyApp in the background.

Objective and problem:
I want to restart MyApp when it crashes. I tried to find out how that is done. Looks like I have to add an entry into /etc/inittab from various links I read. So I added the following entry into /etc/inittab.

MyApp:12345:respawn:MyApp

Question:
Above does not seem to work and how can I get this to work correctly? What is the wrong that I am doing here?

Note:
I am doing a killall -9 MyApp and expeciting it to restart because of the entry I added to /etc/inittab. Is this expectation correct?

TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159

2 Answers2

2
case ${PARAM} in
    start)
        (while :; do MyApp ;done) &
        ;;
Ipor Sircer
  • 3,069
  • 3
  • 10
  • 15
0

This answer comes rather late, but your unique ID in the line you wrote is 5 characters. The maximum lenght for the ID must be 4.