The following script does the database checking automatically:
check_database()
{
if [ `ps -fu oracle | grep smon | wc -l` -gt 0 ] ; then
echo “Database is up and running ” > $status # Just store the status
in a temp file
else
sleep 900 # just sleep for 15 min
if [ `ps -fu oracle | grep smon | wc -l` -eq 0 ] ;then
echo” Database is unavailable for this moment ” >$status_not #
Just store the status in a temp file
fi
fi
}
Thanks to sanjeeb mohapatra for sharing this script.