LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-15-2013, 07:46 PM   #1
manickaraja
Member
 
Registered: Sep 2003
Location: India
Posts: 36

Rep: Reputation: 0
Query on shell script


Hi,
I have a requirement to scan Oracle's alert log file. This file logs all event for Oracle database and each line will have timestamp followed by messages (which might be one or more lines).
Example.
Thu Aug 15 17:35:59 2013
VKTM detected a time drift. Please check trace file for more details.

I have a requirement to scan this log to fine last 5 minutes worth of data entered on this. Could you please help me with the same.

Thanks in advance for your help.

Thanks,
Manick.
 
Old 08-15-2013, 08:27 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,662

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Sure, we'll be glad to help. So post what you've written so far. But we're not going to write your scripts for you.
 
Old 08-15-2013, 08:46 PM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
date --date="5 min ago"

you may need to play around with the output format
man date
for details

then you could just grep that date, with a silly 'after' ( -A 5000 )

Code:
FiveMinAgo="$(date +"%b %d %H:%M" --date="5 min ago")
SixMinAgo="$(date +"%b %d %H:%M" --date="6 min ago")

grep -A 5000 "${FiveMinAgo}" /path/to/log.log || grep -A 5000 "${SixMinAgo}" /path/to/log.log
don't know how often that log is written to
You may need to be 'smarter'
but you have something to work with ( don't expect the above to be fool proof, it isn't )
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script query - How do I achieve the results manya Programming 4 02-07-2010 01:23 AM
Passing a variable from shell script to mysql query? ne00 Programming 1 06-10-2009 11:11 AM
Possible to call a shell script within a mysql query? zhjim Linux - Server 2 08-30-2007 02:23 AM
msyql query from shell script hamish Linux - Software 5 06-02-2006 09:06 AM
Simple shell script query sachinh Programming 5 09-07-2005 04:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration