Oracle – Remove Old Trace File In Oracle Using Shell Script

PC & Tech Category

Below scripts are purged the trace file greater than 15 days. Once executed the scripts its automatically trigger the mail to user with before purge status & after purge status information.

SCRIPT #1

##############################################################################


REMOVE THE OLD TRACE FILES
CREATED BY RAJABASKAR THANGARAJ 12-12-2008

##############################################################################

$ cat oldtrace_remove.sh

#!/bin/ksh
echo Removing older trace file greater than 15 days …..
#run the environment variable profile
. $HOME/.bash_profile
PATH=/opt/app/oracle/admin
cd $PATH/$ORACLE_SID
RUNDATE=`date “+%d%m%y at %H:%M:%S”`
LOGFILE=/home/oracle/dbatest/raja/archived
# -mtime +15 remove the older trace file greater than 15 days
#change the days depend upons your need
du -m > $LOGFILE/before_purged_size.log
find $PATH/$ORACLE_SID/udump/*.trc -mtime +15 -exec rm {} ;
find $PATH/$ORACLE_SID/bdump/*.trc -mtime +15 -exec rm {} ;
find $PATH/$ORACLE_SID/adump/*.trc -mtime +15 -exec rm {} ;
du -m > $LOGFILE/after_purged_size.log
cat $LOGFILE/beforepurgestmt.log $LOGFILE/before_purged_size.log $LOGFILE/afterpurgestmt.log $LOGFILE/after_purged_size.log
> $LOGFILE/mail.log
mail -s “Status of $ORACLE_SID Old trace file successfully purging on $RUNDATE ” [email protected] < $LOGFILE/mail.log
exit;

********************************************************

SCRIPT #2


Below formatted log files are located in /home/oracle/dbatest/raja/archived.


$ cat beforepurgestmt.log

************************************************

BEFORE PURGING THE TRACE FILE SIZE IN MB

*************************************************

SCRIPT #3


Below formatted log files are located in /home/oracle/dbatest/raja/archived.


$ cat afterpurgestmt.log

********************************************************

AFTER PURGING THE TRACE FILES SUCCESSFULLY.SIZE IN MB

*********************************************************

OUTPUT MAIL FORMAT:

SUBJECT:

Status of orcl Old trace file successfully purging on 121208 at 19:17:16

CONTENT:

************************************************

BEFORE PURGING THE TRACE FILE SIZE IN MB

*************************************************

1056 ./adump

100 ./scripts

2056 ./cdump

10024 ./dpdump

3824 ./udump

38240 ./bdump

10 ./pfile
.

********************************************************

AFTER PURGING THE TRACE FILES SUCCESSFULLY.SIZE IN MB

*********************************************************

512 ./adump

1 ./scripts

512 ./cdump

10024 ./dpdump

1024 ./udump

503 ./bdump

10 ./pfile

*******************************************************************************


I Hope this article helped you to understand the remove the old files.Suggestions are welcome.


Tags:

Edward Ramamoorthy Avatar

Help Us Grow

If you like this post, please share it with your friends.

You are free to copy and redistribute this article in any medium or format, as long as you keep the links in the article or provide a link back to this page.

Subscribe to Newsletter




Privacy Settings

Privacy & Cookie Overview

Our website uses cookies to provide you with the best user experience possible. These cookies are stored in your browser and perform essential functions such as recognizing you when you return to our website, as well as helping us to understand which sections of the website you find most useful and engaging.

To learn more, you can read our Privacy & Cookie Policy or reach out through our Contact form.

Strictly Necessary Cookies

Strictly Necessary Cookies must always be enabled to ensure the proper functioning of this website and to allow us to provide you with excellent service. These cookies are also essential for saving your cookie preferences.

Google Adsense

We use Google AdSense to keep this site free by displaying relevant ads. AdSense requires essential cookies that cannot be disabled, but you can manage other cookies. We respect your privacy and provide options to control non-essential cookies.

For more details on how Google handles your data, visit Google's Data Usage Policy. Please review our Privacy Policy for more information on how we protect your data.

AddToAny

We use AddToAny for social sharing. It doesn’t store cookies, ensuring a privacy-friendly experience. AddToAny complies with GDPR and CCPA by default.

For more, see their Privacy Policy.

OneSignal

We use OneSignal to send notifications to users who opt in. OneSignal complies with GDPR and is certified under the EU-US and Swiss-US Privacy Shield frameworks.

For more, see their Privacy Policy.

3rd Party Cookies

This website utilizes third-party cookies, which can enhance your experience and support our ongoing efforts to improve our services.

Google Analytics

We use Google Analytics to collect anonymous data, such as visitor numbers and popular pages, to improve user experience and site performance. Keeping this cookie enabled helps us refine the site based on visitor activity.

For more information, see Google’s Privacy Policy.

Discover more from Prime Inspiration

Subscribe now to keep reading and get access to the full archive.

Continue reading