DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Friday, July 13, 2018

Monthly Count of Database Startup And Shutdown


Steps
 
      -Set Your Environment file or .bash_profile
        - export Your ORACLE_SID
         -Save the Below Script in “.sh” format

Monthly Count of Database Startup :

#!/bin/sh
date
location=`find / -name alert_$ORACLE_SID.log 2>/dev/null`
read -p "Please enter which year you want  : " year
echo -e "\e[96m Month in based on your Oracle Version \e "
echo -e "\e[31m Up to 12.1 enter month in words ie:Jul,Aug,Jan.... in 12.2 enter month in numbers ie:02,03,07...."
echo -e "\e[39m"
read -p "Select any Month Please : " month
read -p "If you need DB Startup status in detail ? (y/n):" a
if test "$a" = "y"
then
cat $location | grep -B2 "Starting ORACLE instance" | grep -i $year | grep -i $month
else
cat $location | grep -B2 "Starting ORACLE instance" | grep -i $year | grep -i $month | wc -l
fi

 
 




Monthly Count of Database Downtime :

#!/bin/sh
date
location=`find / -name alert_$ORACLE_SID.log 2>/dev/null`
read -p "Please enter which year you want  : " year
echo -e "\e[96m Month in based on your Oracle Version \e "
echo -e "\e[31m Up-to 12.1 enter month in words ie:Jul,Aug,Jan....in 12.2 enter month in numbers ie:02,03,07....:"
echo -e "\e[39m"
read -p "Select any Month Please : " month
read -p "If you need DB Shutdown status in detail ? (y/n):" a
if test "$a" = "y"
then
cat $location | grep -B2 "Instance shutdown complete" | grep -i $year | grep -i $month
else
cat $location | grep -B2 "Instance shutdown complete" | grep -i $year | grep -i $month | wc -l
fi