Auto-restart process script.

March 2, 2014 1.8k 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 =(
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 &;
fi
Saved as watchdogblack.sh.
When i try to execute it error message appears:

watchdogblack.sh: line 4: syntax error near unexpected token `;'
watchdogblack.sh: line 4: `then /tmp/murmur/black.x86 & ;
dont break the lines

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

(sorry small typo, and i cant find an edit link)
Have another answer? Share your knowledge.