Thinking Out Loud

January 19, 2012

Rotate Alert Log 11g

Filed under: 11g,oracle — mdinh @ 5:14 am

Tested on Solaris 10

> cat rotate_alert.sh
#!/bin/sh

DN=`dirname $0`
BN=`basename $0`

. /home/oracle/.common.conf > /dev/null
month=`date “+%m”`
for sid in `ps -eo args|grep ora_smon|grep -v grep|awk -F_ ‘{print $3}’`
do
ORACLE_SID=$sid
. oraenv
diag_trace=`$ORACLE_HOME/bin/sqlplus -SL / <<EOF
set echo off ver off feedb off head off pages 0
select value from v\\$diag_info where name=’Diag Trace’;
exit;
EOF
`
alert_log=$diag_trace/alert_$sid.log
mv $alert_log $alert_log.$month
gzip -f $alert_log.$month
touch ${alert_log}
done
exit

NOTE: there is a back-tick (`) in the line after EOF

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: