In order to know, if a process is running or gone, I can suggest you two methods:
1) Use
pidof <name of your program> and check its return value which should be any number as the pid of your process but should not be zero. So if you get zero as return value, means the process is gone.
2) You may use
ls /proc/<pid_of_your_process> should be sucessful. Meaning check the value of $? immediately and the decide, if your process is running or gone.
Now write a parent script which loops for ever (like
while (1) ...) and checks the process state everytime, if your process is found to be not running then invoke the process again and sleep for a reasonable time to allow the process up and running before your this parent script loops to check the status of your process for the next time.
Also invoke your process, from this parent script, using
nohup <your_process_name> &, as you would be knowing to allow your process run in the background and asynchronously to this script.
Cheers!!!!!!!!!!!!