Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> I think this is a better way to get alert from alert.log
In May there was a thread
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=3c37534ece5e3937&rnum=2
talking about how to get alert about errors/warnings from alert.log.
Recently I started to do a similar thing in a new way. Instead of
periodically scanning these log files, why not do what tail -f does?
So here's the command I use:
nohup tail -f thelog | nohup nawk '/SomeString/ {system("mailx -s CheckLogNow youremail < /dev/null")}' &
You can avoid "Sending output to nohup.out" if you launch it from csh. You need nawk or gawk because awk's system command may be broken. You do need two nohup's since nohup doesn't allow command sequences. You can also put the command sequences without nohup in a script and nohup thescript &.
This approach is lighter-weight than the common method using a cron job. It also sends a notice to you as soon as the SomeString (such such ^ORA-00600 where ^ means line beginning) shows up in thelog instead of waiting till your cron job runs next time.
If you use Windows, you have to use David Korn's UWin, Microsoft's Windows Services for UNIX (I'm really impressed by this one), Hamilton Lab's CShell for Windows, MKS, Cygwin or others similar.
Critique is welcome.
Yong Huang Received on Tue Jul 30 2002 - 11:05:32 CDT