Operating System - HP-UX
1835200 Members
2356 Online
110077 Solutions
New Discussion

Re: How can I check a log with a script

 
yalin zhao
Advisor

How can I check a log with a script

Hi,

I want to run a script through cron aimed at following:

To see if the Sybase database backup successful.
To get error messages from its log file (see the attachment).

Thanks for those who will give me some solutions.

Yalin
3 REPLIES 3
harry d brown jr
Honored Contributor

Re: How can I check a log with a script


Why not just monitor the return code from the sybase backup?

OR

use grep with the "-e" option(s) to look for multiple KEYWORDS, like this:

grep -i -e "Backup Server" -e error ssprod_back.log


??

live free or die
harry
Live Free or Die
Trever Furnish
Regular Advisor

Re: How can I check a log with a script

Actually, although I agree with the spirit of Harry's suggestion (grep is your friend), I would suggest that instead of looking for patterns you know represent errors, you should *exclude everything except the patterns you know are good*. That way when something unexpected pops up for the first time, you'll still catch it.

So again, what you do is build a list of the patterns you know you can ignore.

Then filter those out and let everything else come through - your goal should be to filter out everything you don't care about, so you only see the important stuff.

For example, you might use:
grep -v -e 'backup successful' -e 'startup successful' -e 'checkpoint completed' -e 'logged in at' -e 'new log file opened'.

Over time, keep adding to the list for log entries you want to ignore and you will end up with a nice log watcher.

Actually, there's already a system available to do exactly that, called logwatch. You'd probably have to adjust it a little to get it working on hpux, and you would definitely have to write a small module to plug your filter into.

Logwatch is probably overkill unless you plan on watching more than one type of log file.

http://www.logwatch.org/
Hockey PUX?
yalin zhao
Advisor

Re: How can I check a log with a script

Thanks Harry and Trever,

What will be the command if I want to grep the specific date? for instance, the following line shows:

Nov 13 04:33:55 2002: Backup Server: 4.15.2.2: Label validation error: seek to trailer labels failed.


It will show everything in the past if I do not indicate the date.Suggestions?

Yalin