# Verify if the script is already running, in that case we exit with an error

if [ -f /tmp/${PRGRM}.pid ] then

echo "ERROR : Script is already running, exiting ..."

exit 99

else

echo $ > /tmp/${PRGRM}.pid

fi

}

And to use it, just call the function like this:

#checking lock file: is script already running?check_lock_file

Creating an infinite loop to respawn process when they are dead. Can
be used to auto-respawn a killed process (when you change his config
file and have to restart it). Can also be used with a crontab killing
the process in order for the process to be "fresh". Launch this as a
"nohup &" with redirected output to /dev/null (>/dev/null).