Part of log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Part of log
# 1  
Old 03-05-2013
Part of log

hi,

i have a requirement where i need to grep the part of the log file of last 5 minutes back.

Code:
[10/2/08 9:40:39:865 EDT] 00000011 ViewReceiver  I   DCSV1033I: DCS Stack DefaultCoreGroup at Member usa0300ux423Cell01\usa0300ux423QASrv02\server1: Confirmed all new view members in view identifier (11:0.usa0300ux423Cell01\usa0300ux423QASrv01\server1). View channel type is View|Ptp.

please suggest??

Last edited by Scrutinizer; 03-05-2013 at 08:18 AM.. Reason: code tags
# 2  
Old 03-05-2013
Code:
awk '$0>=from && $0<=to' from="$(date +"[%x %H:%M:%S" -d -5min)" to="$(date +"[%x %H:%M:%S")" logfile

You may need to tune the date format to reflect your log

Last edited by Jotne; 03-05-2013 at 09:10 AM..
# 3  
Old 03-05-2013
thanks for the reply Jotne, but i have 1 question here:
Code:
%x %H:%M:%S" -d 5min

in the from clause you have written this code but it only gives the current time, how
Code:
bash-3.2$ date +"[%x %H:%M:%S" -d 5min
[03/05/13 08:00:06
bash-3.2$ date
Tue Mar  5 08:00:13 EST 2013

how could i go back 5 minutes?

Last edited by Franklin52; 03-05-2013 at 09:41 AM.. Reason: Please use code tags for data and code samples
# 4  
Old 03-05-2013
Use Code tag please
My line above take the last 5 minutes form the log -d -5min
It goes form now and 5 minute back and return every line within that time frame.

This give now date +"[%x %H:%M:%S" [03/05/13 14:06:10
This give -5 min date +"[%x %H:%M:%S" -d -5min [03/05/13 14:01:10

Edit
Fixed small typo, missing a -
# 5  
Old 03-05-2013
but i am getting the same result as i was getting earlier:
Code:
bash-3.2$ date +"[%x %H:%M:%S" -d -5min
[03/05/13 09:20:51
bash-3.2$ date
Tue Mar  5 09:21:00 EST 2013

may be because i am working on solaris env??
please help with some more ideas..

Last edited by Franklin52; 03-05-2013 at 10:49 AM.. Reason: Please use code tags for data and code samples
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to make a loop to read the input from a file part by part?

Hi All, We've a VDI infrastructure in AWS (AWS workspaces) and we're planning to automate the process of provisioning workspaces. Instead of going to GUI console, and launching workspaces by selecting individual users is little time consuming. Thus, I want to create them in bunches from AWS CLI... (6 Replies)
Discussion started by: arun_adm
6 Replies

2. Shell Programming and Scripting

How to extract part of string from all log files.?

Hi All, Let us say we have 5 log files, extract the data from all log files and save the output in a file. home/log/first.log home/log/second.log home/log/third.log home/log/four.log home/log/five.log I want to extract the following text from the log files and save the output in a file.... (7 Replies)
Discussion started by: ROCK_PLSQL
7 Replies

3. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

4. Shell Programming and Scripting

Getting the date part from the log file.

Hi, I have a script that runs to generate a log file which is in this format: Start: Friday, April 29, 2011 18:30 User : Host : Database : I need to write a script that reads this log file (RUN.LOG) and rename the existing log file... (7 Replies)
Discussion started by: ashok@119
7 Replies

5. Shell Programming and Scripting

Get a part of a String from a log file

Hey there, I'm searched for one day your forum for a similar solution. Didn't find one, sorry :( Now here is what I'm searching for. I have the following multiple lines from a log (Edit: log name is SystemOut.log - this is not my day. I Apologize): 000042e2 1_BLA_Yab I logging.LogInfo... (5 Replies)
Discussion started by: nobodyhere
5 Replies

6. Shell Programming and Scripting

Tailing last modified part of log file

I have a log file which contains data like this This log file is updated twice a day at 7am and 6pm, I want a script(which i will make run at 7:10am and 6:10pm) which should fetch only the last appended lines since last update.. I mean.. if i execute the script at 7.10am 3/3/2010 it... (4 Replies)
Discussion started by: user__user3110
4 Replies

7. Shell Programming and Scripting

get the part of log between 2 string

Hi Let's say I have a log file with this format: Marker1 End of Marker1 .... Marker1 End of Marker1 .... Marker1 End of Marker1 how to get the last part between End of Marker1 and Marker1? (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

8. Shell Programming and Scripting

comparing part of header with part of detailed records.

Hi there, I am lil confused with the following issue. I have a File, which has the following header: IMSHRATE_043008_101016 a sample detailed record is :9820101 A982005000CAVG030108000000000000010169000MAR 2008 9820102 MAR 2008 D030108 ... (1 Reply)
Discussion started by: cmaroju
1 Replies

9. Shell Programming and Scripting

How to extract certain part of log file?

Hi there, I'm having some problem with UNIX scripting (ksh), perhaps somebody can help me out? For example: ------------ Sample content of my log file (text file): -------------------------------------- File1: .... info_1 ... info_2 ... info_3 ... File2: .... info_1 ... info_2 ...... (10 Replies)
Discussion started by: superHonda123
10 Replies

10. Shell Programming and Scripting

help me in this part

why we use strcpy and strcat in KSH program?? (1 Reply)
Discussion started by: debasis.mishra
1 Replies
Login or Register to Ask a Question