How to see record for particular date from a log file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to see record for particular date from a log file
# 1  
Old 11-30-2007
How to see record for particular date from a log file

Hi Experts,

I 'm a Oracle Dba, everytime if have to see the alert log file. I used tail command to see the last few line of the log file. I wished if i could see record for the particular date(e.g nov 23), here is sample log file.


Wed Nov 28 21:43:59 2007
Control autobackup written to SBT_TAPE device
comment 'API Version 2.0,MMS Version 5.0.0.0',
media 'WP0202'
handle 'c-2861328927-20071128-00'
Wed Nov 28 21:44:08 2007
Thread 1 advanced to log sequence 142
Current log# 2 seq# 142 mem# 0: /oracle/NEWDB/oradata/NEWDB/redo2.log
Wed Nov 28 21:44:08 2007
ARCH: Evaluating archive log 3 thread 1 sequence 141
ARCH: Beginning to archive log 3 thread 1 sequence 141
Wed Nov 28 21:44:08 2007
ARC1: Evaluating archive log 3 thread 1 sequence 141
ARC1: Unable to archive log 3 thread 1 sequence 141
Log actively being archived by another process
Wed Nov 28 21:44:08 2007
Creating archive destination LOG_ARCHIVE_DEST_1: '/oracle/NEWDB/admin/arch/1_141.dbf'
Wed Nov 28 21:44:08 2007
ARC0: Evaluating archive log 3 thread 1 sequence 141
ARC0: Unable to archive log 3 thread 1 sequence 141
Log actively being archived by another process
Wed Nov 28 21:44:08 2007
ARCH: Completed archiving log 3 thread 1 sequence 141
Wed Nov 28 21:44:09 2007
Thread 1 advanced to log sequence 143
Current log# 1 seq# 143 mem# 0: /oracle/NEWDB/oradata/NEWDB/redo1.log
Wed Nov 28 21:44:09 2007
ARCH: Evaluating archive log 2 thread 1 sequence 142
ARCH: Beginning to archive log 2 thread 1 sequence 142
Creating archive destination LOG_ARCHIVE_DEST_1: '/oracle/NEWDB/admin/arch/1_142.dbf'
Wed Nov 28 21:44:09 2007
ARC0: Evaluating archive log 2 thread 1 sequence 142
ARC0: Unable to archive log 2 thread 1 sequence 142
Log actively being archived by another process
Wed Nov 28 21:44:09 2007
ARCH: Completed archiving log 2 thread 1 sequence 142
Wed Nov 28 21:44:36 2007
Starting control autobackup
Wed Nov 28 21:45:00 2007
Control autobackup written to SBT_TAPE device
comment 'API Version 2.0,MMS Version 5.0.0.0',
media 'WP0202'
handle 'c-2861328927-20071128-01'
Clearing standby activation ID 2873610446 (0xab47d0ce)
The primary database controlfile was created using the
'MAXLOGFILES 5' clause.
The resulting standby controlfile will not have enough
available logfile entries to support an adequate number
of standby redo logfiles. Consider re-creating the
primary controlfile using 'MAXLOGFILES 8' (or larger).
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 10485760;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 10485760;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 10485760;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 10485760;
Thu Nov 29 21:36:44 2007
Starting control autobackup
Thu Nov 29 21:42:53 2007
Control autobackup written to SBT_TAPE device
comment 'API Version 2.0,MMS Version 5.0.0.0',
media 'WP0206'
handle 'c-2861328927-20071129-00'
Thu Nov 29 21:43:01 2007
Thread 1 advanced to log sequence 144
Current log# 3 seq# 144 mem# 0: /oracle/NEWDB/oradata/NEWDB/redo3.log
Thu Nov 29 21:43:01 2007
ARCH: Evaluating archive log 1 thread 1 sequence 143
ARCH: Beginning to archive log 1 thread 1 sequence 143
Creating archive destination LOG_ARCHIVE_DEST_1: '/oracle/NEWDB/admin/arch/1_143.dbf'
Thu Nov 29 21:43:01 2007
ARC1: Evaluating archive log 1 thread 1 sequence 143
ARC1: Unable to archive log 1 thread 1 sequence 143
Log actively being archived by another process
Thu Nov 29 21:43:02 2007
ARCH: Completed archiving log 1 thread 1 sequence 143
Thu Nov 29 21:43:03 2007
Thread 1 advanced to log sequence 145
Current log# 2 seq# 145 mem# 0: /oracle/NEWDB/oradata/NEWDB/redo2.log
Thu Nov 29 21:43:03 2007
ARCH: Evaluating archive log 3 thread 1 sequence 144
ARCH: Beginning to archive log 3 thread 1 sequence 144
Creating archive destination LOG_ARCHIVE_DEST_1: '/oracle/NEWDB/admin/arch/1_144.dbf'
# 2  
Old 11-30-2007
Try...
Code:
awk '/Nov 28/,/Nov 29/' file1 | sed '$d'

# 3  
Old 11-30-2007
Hi,
Can you please tell me, alert_NEWDB.log is the file. How do i apply your command.

Thanks
Shaan
# 4  
Old 11-30-2007
Replace file1 with the name of your file Smilie
# 5  
Old 11-30-2007
Hi Expert,

The result it is showing is this

awk '/Nov 28/' alert_NEWDB.log | sed '$d'
Wed Nov 28 21:43:31 2007
Wed Nov 28 21:43:59 2007
Wed Nov 28 21:44:08 2007
Wed Nov 28 21:44:08 2007
Wed Nov 28 21:44:08 2007
Wed Nov 28 21:44:08 2007
Wed Nov 28 21:44:08 2007
Wed Nov 28 21:44:08 2007
Wed Nov 28 21:44:09 2007
Wed Nov 28 21:44:09 2007
Wed Nov 28 21:44:09 2007
Wed Nov 28 21:44:09 2007
Wed Nov 28 21:44:36 2007
# 6  
Old 12-01-2007
Why don't you try what was suggested above?

The awk script prints all lines from the start pattern, "Nov 28" until the end pattern, "Nov 29". The sed script deletes the last line, i.e. the "Nov 29" line.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

2. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

3. Shell Programming and Scripting

Appending error messages from log file next to the corresponding error record

Hi Everyone, I have an issue and trying to get a solution but was not succesful yet. Any help is greatly appreciated. I am using ksh to inoke sql loader to load data from txt file into two oracle tables based on the condition written in the control file. If an error occurs while loading into... (8 Replies)
Discussion started by: vpv0002
8 Replies

4. Shell Programming and Scripting

Delete log file entries based on the Date/Timestamp within log file

If a log file is in the following format 28-Jul-10 ::: Log message 28-Jul-10 ::: Log message 29-Jul-10 ::: Log message 30-Jul-10 ::: Log message 31-Jul-10 ::: Log message 31-Jul-10 ::: Log message 1-Aug-10 ::: Log message 1-Aug-10 ::: Log message 2-Aug-10 ::: Log message 2-Aug-10 :::... (3 Replies)
Discussion started by: vikram3.r
3 Replies

5. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

6. UNIX for Dummies Questions & Answers

how to read record by record from a file in unix

Hi guys, i have a big file with the following format.This includes header(H),detail(D) and trailer(T) information in the file.My problem is i have to search for the character "6h" at 14 th and 15 th position in all the records .if it is there i have to write all those records into a... (1 Reply)
Discussion started by: raoscb
1 Replies

7. Shell Programming and Scripting

Processing a log file based on date/time input and the date/time on the log file

Hi, I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies

8. Shell Programming and Scripting

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (2 Replies)
Discussion started by: shilendrajadon
2 Replies

9. UNIX for Advanced & Expert Users

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (1 Reply)
Discussion started by: shilendrajadon
1 Replies

10. Shell Programming and Scripting

splitting a record and adding a record to a file

Hi, I am new to UNIX scripting and woiuld appreicate your help... Input file contains only one (but long) record: aaaaabbbbbcccccddddd..... Desired file: NEW RECORD #new record (hardcoded) added as first record - its length is irrelevant# aaaaa bbbbb ccccc ddddd ... ... ... (1 Reply)
Discussion started by: rsolap
1 Replies
Login or Register to Ask a Question