Getting logs between two times


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting logs between two times
# 1  
Old 01-18-2010
Getting logs between two times

Hi,
I need to read log file for the period between two time frame.eg all those logs between 3AM to 4M.
Any command to use for the shell scripting?

Ahamed
# 2  
Old 01-18-2010
An example:

Code:
awk '/begin time/{p=1} /end time/{p=0} p' logfile

# 3  
Old 01-18-2010
Hi,
I think the awk library is not installed in my system. I tried executing the command but i m not getting any output.

Is there any other command to get logs between two time frame. The time format is hh:mm:ss.Can date also be included while reading the file?

I want the logs for the particular day and particular time.

Ahamed.
# 4  
Old 01-18-2010
The given example extracts lines between 2 patterns, not times. To get lines between arbitrary times you can use a shell script. Here you can find a time arithmic example:

Difference between two timestamps

More examples:

https://www.unix.com/answers-frequent...rithmetic.html
# 5  
Old 01-19-2010
The logs contain lines like

06:19:01,256 [Task Engine Worker 1] ...

06:19:01,402 [Task Engine Worker 3]...

I need to get all the lines between 06:00:00 to 07:00:00

can someone help me with the command

Ahamed.
# 6  
Old 01-19-2010
What about this?
Code:
sed -n -e '/^06/,/^07:00:00/p' logfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. Shell Programming and Scripting

To get difference between 2 times.

Can anyone help me to write a script to get diffrence between 2 times. (platform- solaris) i.e., Diffence shoud be displayed in tems of hours. (Approximately) for eg: file1 = 05-Apr-2012 13:42:32 file2 = 04-Apr-2012 12:42:41 O/P is like : diff = 25 Hrs (2 Replies)
Discussion started by: thomasraj87
2 Replies

3. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

4. UNIX and Linux Applications

ssh times out

I have fedora 13 installed on my home computer. I am unable to ssh from my office to my home computer. On trying to ssh to my home computer, I get the following response: $ ssh -vvv username@129.X.XXX.XXX OpenSSH_5.3p1, OpenSSL 1.0.0a-fips 1 Jun 2010 debug1: Reading configuration data... (6 Replies)
Discussion started by: arbitguy
6 Replies

5. Shell Programming and Scripting

finding out how many times something comes up

Hi, I have a file that looks something like this: YPA124 NV YPA124 NV YPA124 V YAR198 V YAR198 V YOB911 V YOB911 V YOB911 NV YOB911 NA So what i want to do is find out how many times each name on column 1 is represented by indicators on column 2. So the output would... (4 Replies)
Discussion started by: phil_heath
4 Replies

6. Shell Programming and Scripting

Exit if between 2 times

Hello, I am working in Solaris 10 with a Bash script and trying to figure out how I can tell the script to look at the day of the week and the time and for example if it is Sat between 5:50am and 6:30am then just exit out of the script. Any other day or time keep running. We have a... (3 Replies)
Discussion started by: LRoberts
3 Replies

7. UNIX for Dummies Questions & Answers

comparing two times

Hi Good Morning all, I have two dates and times in the beloe format. 1. 07/18/2009 03:45:49 2. 07/18/2009 03:46:41 i will grep these values from a file. Now my problem is i need to find out whether the second valus is bigger thatn the 1 value. How to compare the times. Please help me in... (4 Replies)
Discussion started by: intiraju
4 Replies

8. AIX

how would you know your server was rebooted 3 times or 5 times

Is there such location or command to know how many times did you reboot your server in that particular day?in AIX. (3 Replies)
Discussion started by: kenshinhimura
3 Replies

9. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

Hi, I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows: """"""""""""""""""""""""""... (3 Replies)
Discussion started by: harish.parker
3 Replies

10. UNIX for Advanced & Expert Users

Boot times

Hey all, What we have at work is a Themis board (VME rack SPARC system). We have to try to have the boot time as fast as can be. What we have already done is make some filesystems read only so if power is lost then the filesystem check will not run. This is only done to the partitions that... (2 Replies)
Discussion started by: woofie
2 Replies
Login or Register to Ask a Question