Introduction: 

There are many times where DBA has to run tkprof for multiple trace files at one time and get them uploaded in Oracle SR.  Here, I will be sharing one such easy way to perform such tasks.

How to find the trace files?

Sometimes, we receive such requests with trace filenames and incase if you don’t receive it, you can always search using the module name (like *WMS*) or concurrent request short name.

grep *WMS* *ora*trc

If you know some pattern, you can use that in your commands to filter the trace files.  For instance, I need to filter out trace file created on Feb 25 and I used below command.

[DOYENSYS]$ ls -ltr *ora*trc|grep “Feb 25″|head
-rw-r—– 1 oracle dba 209390 Feb 25 00:11 DOYENSYS1_ora_231457.trc
-rw-r—– 1 oracle dba 1083 Feb 25 00:12 DOYENSYS1_ora_231464.trc
-rw-r—– 1 oracle dba 1083 Feb 25 00:12 DOYENSYS1_ora_231721.trc
-rw-r—– 1 oracle dba 3414 Feb 25 00:12 DOYENSYS1_ora_231715.trc
-rw-r—– 1 oracle dba 2180 Feb 25 01:01 DOYENSYS1_ora_149212.trc
-rw-r—– 1 oracle dba 1181 Feb 25 01:16 DOYENSYS1_ora_362053.trc
-rw-r—– 1 oracle dba 1916 Feb 25 01:50 DOYENSYS1_ora_376693.trc
-rw-r—– 1 oracle dba 1526 Feb 25 04:02 DOYENSYS1_ora_330098.trc
-rw-r—– 1 oracle dba 1527 Feb 25 04:02 DOYENSYS1_ora_278194.trc
-rw-r—– 1 oracle dba 1555 Feb 25 04:02 DOYENSYS1_ora_178964.trc
oracle@prddba01.doyen.com:/u01/app/oracle/diag/rdbms/DOYENSYS/DOYENSYS1/trace
[DOYENSYS]$

The real challenge is to perform tkprof for all the above trace files at a time.  You need to extract the the list of files and write shell script to complete the tasks. But I will propose a solution as follows.

Solution:

If you need to perform tkprof for all trace files listed above, just perform below.

[DOYENSYS]$ls -ltr *ora*trc|grep “Feb 25″|awk {‘print $9’}|cut -d ‘.’ -f1|xargs -i -t tkprof {}.trc {}.txt explain=apps/apps sort='(prsela,exeela,fchela)’

 

The above command creates the tkprof file in the same working directory with .txt as extension.

Now, you can zip all the files and complete the tasks.

 

Enjoy your rest of the time!!!

Recent Posts

Start typing and press Enter to search