export ORACLE_SID=$1;
sqlplus / as sysdba <<EOF >/dev/null
set heading off;
spool trace_dir.log;
select value from v\$diag_info where name ='Diag Trace';
spool off;
set heading on;
EOF
v_trace_dir=`cat trace_dir.log | grep -i $1`;
if [ -n $v_trace_dir ]
then
cd $v_trace_dir;
print "-----------------------------------------------------------------------------";
print "Oracle Instance $1. Trace Dir is:";
print `pwd`;
print "-----------------------------------------------------------------------------";
print "Do you want to delete trace file: ? (yes/no)";
read user_answer
if [ $user_answer='yes' ]
then
print "-----------------------------------------------------------------------------";
print "You are selected: $user_answer. This script will delete trace file.";
for i in $( ls *.trc )
do
print "Deleting $i";
rm $i;
done;
for i in $( ls *.trm )
do
print "Deleting $i";
rm $i;
done;
print "Backup alert_$1.log to alert_$1.log.`date +%d-%m-%y`";
cp alert_$1.log alert_$1.log.`date +%d-%m-%y`;
echo /dev/null > alert_$1.log;
print "Done;";
exit;
else
print "-----------------------------------------------------------------------------";
print "You selected: $user_answer. This script will exit as normal."
exit;
fi;
else
print "Can't find Trace Dir. This script will exit as normal;";
fi;
sqlplus / as sysdba <<EOF >/dev/null
set heading off;
spool trace_dir.log;
select value from v\$diag_info where name ='Diag Trace';
spool off;
set heading on;
EOF
v_trace_dir=`cat trace_dir.log | grep -i $1`;
if [ -n $v_trace_dir ]
then
cd $v_trace_dir;
print "-----------------------------------------------------------------------------";
print "Oracle Instance $1. Trace Dir is:";
print `pwd`;
print "-----------------------------------------------------------------------------";
print "Do you want to delete trace file: ? (yes/no)";
read user_answer
if [ $user_answer='yes' ]
then
print "-----------------------------------------------------------------------------";
print "You are selected: $user_answer. This script will delete trace file.";
for i in $( ls *.trc )
do
print "Deleting $i";
rm $i;
done;
for i in $( ls *.trm )
do
print "Deleting $i";
rm $i;
done;
print "Backup alert_$1.log to alert_$1.log.`date +%d-%m-%y`";
cp alert_$1.log alert_$1.log.`date +%d-%m-%y`;
echo /dev/null > alert_$1.log;
print "Done;";
exit;
else
print "-----------------------------------------------------------------------------";
print "You selected: $user_answer. This script will exit as normal."
exit;
fi;
else
print "Can't find Trace Dir. This script will exit as normal;";
fi;

Không có nhận xét nào:
Đăng nhận xét