Saturday, August 8, 2009

Monitoring Linux Process

This script will monitor for a process for its running status. If the process is down it will take action accordingly.

------------------------------
#!/bin/sh
process_name=?
pid=`ps -ef grep $process_name grep -v grep awk '{ print $2 }'`
if [ -z $pid ]
then
echo "Process is not running"
else
echo "Process is running with ID $pid"
fi
--------------------------------------------


Hope this will help admins to monitor processes and take action accordingly.