Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find and tail the Oracle alert log

When you take your first look at an Oracle database, one of the first questions is often "where's the alert log?". Grid Control can tell you, but its often not available in the environment.

I posted some bash and Perl scripts to find and tail the alert log on my blog some time back, and I'm surprised to see that post still getting lots of hits.

The technique used is to lookup background_dump_dest from v$parameter. But I only tested this on Oracle Database 10g.

Is there a better approach than this? And does anyone know if this still works in 11g?

like image 679
tardate Avatar asked Oct 05 '08 12:10

tardate


2 Answers

Am sure it will work in 11g, that parameter has been around for a long time.

Seems like the correct way to find it to me.

If the background_dump_dest parameter isn't set, the alert.log will be put in $ORACLE_HOME/RDBMS/trace

like image 66
cagcowboy Avatar answered Sep 21 '22 06:09

cagcowboy


Once you've got the log open, I would consider using File::Tail or File::Tail::App to display it as it's being written, rather than sleeping and reading. File::Tail::App is particularly clever, because it will detect the file being rotated and switch, and will remember where you were up to between invocations of your program.

I'd also consider locking your cache file before using it. The race condition may not bother you, but having multiple people try to start your program at once could result in nasty fights over who gets to write to the cache file.

However both of these are nit-picks. My brief glance over your code doesn't reveal any glaring mistakes.

like image 33
pjf Avatar answered Sep 23 '22 06:09

pjf