in Linux, Oracle

Oracle database Listener auto recover on RHEL (Script)

Here is a very clean and simple script which will monitor and check the status of listener for oracle database. Once it finds that Listener is stopped it will start it again at the very moment!

#!/bin/bash
# Oracle TNS listener auto recovery script
# Written by ConArtist http://bit.ly/Conartist

logfile=/home/oracle/lsnrrec.log
sleep=10
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
if [ ! -f $logfile ];
then
touch $logfile
fi

while true
do
if pgrep tnslsnr > /dev/null ;then
echo . > /dev/null
else
echo “$(date) — Listener dropped… Restarting TNSLSNR” >> $logfile
$ORACLE_HOME/bin/lsnrctl start > /dev/null
fi
sleep $sleep
done

So here, this script will check the status of tnslsnr and start it, in case of need