Auto-restart process script.

Posted March 2, 2014 2.7k views
Hello. I have a process, that i want to restart if he dies. Process name is black.x86 Directory - /tmp/blackplanet/black.x86 System - CentOS 6.4 Can someone help with correct .sh script? Thanks! PS. Yeah yeah i googled alot, but nothing helped me =(

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers
put this on cron
if [ ! `/usr/bin/pgrep black.x86` ];then /tmp/blackplanet/black.x86 & ;fi
I wrote this script like this
# !/bin/bash

if [ ! `/usr/bin/pgrep murmur.x86` ];
then /tmp/murmur/murmur.x86 &;
Saved as
When i try to execute it error message appears: line 4: syntax error near unexpected token `;' line 4: `then /tmp/murmur/black.x86 & ;
dont break the lines

if [ ! `/usr/bin/pgrep black.x86` ];then /tmp/blackplanet/black.x86 & ;fi
if [ ! `/usr/bin/pgrep black.x86` ];then /tmp/blackplanet/black.x86 & ;fi

(sorry small typo, and i cant find an edit link)