I have some applications that need to run on my laptop all the time.
I use a bash script to start these applications. In my script I have a loop that looks similar to this:
while true;
do
xterm
done
This runs an application (xterm
in this case) and if the application crashes, the loop starts it again.
This has a disadvantage that there is no "clean" exit from this loop. So even if the intention of the user is to close xterm
, the loop starts it again.
Is there a way to start an application from bash script, watch whether it is running, to re-run it if script crashed or do nothing if the user closed it properly ?