-1

I have written a program of TCP server running on OpneWRT OS for MedaTek MT7688 module. Using Init Scripts I am starting my program at boot up. If some how (e.g. segmentation fault) my program get terminated, What is the way to start this program again automatically?

Thanks in advance.

beparas
  • 1,927
  • 7
  • 24
  • 30

1 Answers1

0

To solve this I have wrote a scripts calls monitor.sh

#!/bin/sh

while [ 1 ]; do

    PROCESS=`ps | grep myApp | grep -v grep`

    if [ -z "$PROCESS" ]; then
         echo "Process is not running" 
        /root/myApp  2>/dev/null 1>/dev/null &

    fi

    sleep 3
done
exit 0

Please comment on this.

beparas
  • 1,927
  • 7
  • 24
  • 30