LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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, 08:46 PM   #1
manickaraja
LQ Newbie
 
Registered: Sep 2003
Location: India
Posts: 26

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, 09:27 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,926

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
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, 09:46 PM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:23 AM
Passing a variable from shell script to mysql query? ne00 Programming 1 06-10-2009 12:11 PM
Possible to call a shell script within a mysql query? zhjim Linux - Server 2 08-30-2007 03:23 AM
msyql query from shell script hamish Linux - Software 5 06-02-2006 10:06 AM
Simple shell script query sachinh Programming 5 09-07-2005 05:02 AM


All times are GMT -5. The time now is 06:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration