Since I have develop a script code to do automatic synchronize files between server and clients. The code is designed to run in background. To make sure that the program is still running the following code is used to recognize the running process.
if ps ax | grep -v grep | grep $SERVICE > /dev/null
echo “$SERVICE service running, everything is fine”
echo “$SERVICE is not running” echo “$SERVICE is not running!” | mail -s “$SERVICE down” root
This code can be modified by insert more functions to reach your purposes.