Check if a program is running and if not, run it.
I’ve built myself an OwnCloud server. Unfortunately every time I take the server or it’s router down for maintenance the OwnCloud client program on my desktop dies. To take care of this I created a script that checks if the owncloud client is running and starts it if it is not. Th do this, open at text editor such as gedit and:
if ps ax | grep -v grep | grep $process > /dev/null
then save the file in your home directory. Make sure the name of the program (owncloud) you are checking on is not part of the filename you use here. Otherwise “grep” will see that filename and think owncloud is running and just quit. In my case I used the fiename:
Next make oc_restart executable. Open a terminal and:
chmod +x ~/oc_restart
Alternatively you can change under the properties of the oc_restart file using Nautilus. Finally use Scheduled Tasks to run /.oc_restart every hour.