Keyword search: 

Monitor and Restart on Unix and Linux platforms

5/5/2008 6:32 PM
You can subscribe to this wiki article using an RSS feed reader.

Problem:

Is there a script to monitor and restart FileReplicationPro on Unix and Linux platforms?



Solution:

Below is a script that will monitor FileReplicationPro and restart it if it is not running properly.

#!/bin/bash

while [ true ]
do

# Get FRP status
/usr/bin/wget --tries=1 --timeout=5 http://fm3.surfnetcorp.com:9200 2>&1 | grep "Malformed status"
k=$?

echo "Monitor status is $k"

if [ 1 = $k ]
then
echo "Restarting FRP"
/root/FileReplicationPro/StopFileReplicationPro
sleep 30

# If FRP still did not stop, terminate the process by force
frp_pid=`ps x| grep [F]ileReplicationPro | awk '{print $1}'`

if [ $frp_pid ]
then
kill -9 $frp_pid 2>&1 > /dev/null
echo "Killed FRP process $frp_pid"
fi

sleep 10

# Start FRP
nohup /root/FileReplicationPro/StartFileReplicationPro &
echo "FRP Restarted"
fi

sleep 3600

done
Tags:
Home: WIKI - Knowledge Base Index What's new: Recently changed articles