Showing posts with label Shell Scripts. Show all posts
Showing posts with label Shell Scripts. Show all posts

Saturday, February 6, 2010

Script to gather Stats for list of tables

Store the list of tables in tablelist.lst file.
EMP
DEPT














[oracle@vinay scripts]$ export ORACLE_SID=test1
[oracle@vinay scripts]$ ./gather_tab_stat.sh
Table: EMP Completed
Table: DEPT Completed


Saturday, January 30, 2010

Check alert log

export ALERT_LOG=$BDUMP/alert_$ORACLE_SID.log

tail -200 $ALERT_LOG | grep "ORA-" > $CRONDIR/maint/alert_log_errors.txt

let lc="$(wc -l <$CRONDIR/maint/alert_log_errors.txt)" if ((lc > 0));
then
mailx -s "$ORACLE_SID: Alert Log Errors!!" k@a.com r@a.com < $CRONDIR/maint/alert_log_errors.txt
fi

exp dump clean

find /u06/oradata/export -name "exp*dmp.Z" -ctime +6 -exec rm -f {} \;
find /u06/oradata/export -name "exp*.log" -ctime +6 -exec rm -f {} \;

Check if instance is up or not


#! /bin/ksh
sqlplus -s "/ as sysdba" <>EOF //use less than redirection symbols
set pages 0
set feedback off
spool /tmp/instance_status.log
select status from v\$instance;
spool off
EOF
grep "OPEN" /tmp/instance_status.log
if [$? -eq 0]; then
echo "Instance is up!"
else
echo "Instance is Down!"
fi

Check if Listener is up or not

#! /bin/ksh
LISTENER_NAME=$1
ps -ef|grep "tnslsnr $LISTENER_NAME"|grep -v grep
if[ $? -eq 0 ]; then
echo "The listener $LISTENER_NAME is UP"
else
echo "The listener $LISTENER_NAME is DOWN"
fi