« South Park Me | Main | How to save a mapped drive password in XP »

Simple Script to check if a process is running and if not restart it

I wrote this simple script to check if a process is running and if not restart it

#!/bin/sh
TEST=`pgrep $1`
if [ ! "$TEST" ]
then
$2
else
echo "$1 Alive "
fi

Usage:
check.sh

Example:
check.sh named /usr/local/sbin/named

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)