How to collect the logs with in two time stamp ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to collect the logs with in two time stamp ?
# 1  
Old 11-14-2013
How to collect the logs with in two time stamp ?

Hi Gurus

I need to collect the logs between two time stamp... The log files 12 hours format (ex- Nov 14, 2013 12:10:16 AM UTC) I tried the below commands but no luck.
Code:
awk '$0 >= "Nov 14, 2013 9:40:01" && $0 <= "Nov 14, 2013 9:55:01"' file

Code:
sed -n '/Nov 14, 2013 7:58:00 PM UTC/,/Nov 14, 2013 8:10:00 PM UTC/p' file

awk - since its 12 hours format so I'm facing issue "AM, PM" and in case if time stamp (from=9:40" and to=10:00" then I'm not receiving any output

sed - if the error between the two time stamp then its not working.

please help me on this ....

Note : Modifying the log format (time) not possible

Last edited by Franklin52; 11-15-2013 at 03:26 AM.. Reason: Please use code tags
# 2  
Old 11-14-2013
By example were x.x contains particular filestamps and text and x.awk is an awk script....

Code:
josephgr@oc0887178221 ~]$ cat x.x
one
Nov 14, 2013 9:40:01
foobar
barfoo
Nov 14, 2013 9:55:01
five

[josephgr@oc0887178221 ~]$ cat x.awk
/Nov 14, 2013 9:40:01/ {
print $0
 while ( getline != /Nov 14, 2013 9:55:01/ ) {
    print $0
    }
}

[josephgr@oc0887178221 ~]$ awk -f x.awk x.x
Nov 14, 2013 9:40:01
foobar
barfoo

# 3  
Old 11-14-2013
Thanks for the reply.

can you please help me to understand more on x.awk.



Requirement:
I created the shell script to check the errors from weblogic log files. The script will grep "today date" | egrep 'error1 | error2 | error3' from log files and redirecting to > /home/my-dir/test

then I'm planning to collect past 15 mins log entry from /home/my-dir/test.

since it's 12 hours format so I'm using
Code:
# Time stamp
tot=`date "+%r %Z" | sed 's/^0//'`
to=`date "+%b %d, %Y"`

frmt=`date -d "-20 minutes" "+%r %Z" | sed 's/^0//'`
from=`date "+%b %-d, %Y"`

please let me know what I need to update on x.awk

Last edited by Franklin52; 11-15-2013 at 03:27 AM.. Reason: Please use code tags
# 4  
Old 11-17-2013
Please help me on this ?
# 5  
Old 11-18-2013
guru's

Any suggestion ? it's bit urgent so need your help on this...

---------- Post updated at 02:41 PM ---------- Previous update was at 12:44 PM ----------

blackrageous

Any suggestion, can you please explain more about x.awk
# 6  
Old 11-18-2013
Moderator's Comments:
Mod Comment Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future.


Furthermore,

Moderator's Comments:
Mod Comment Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.

Thank you.

The UNIX and Linux Forums


(Other thread is here)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expect script to collect logs in expert mode

I am trying to collect logs from a system in expert mode. Where I login to system and then change mode to expert mode and issue command to collect the log. I have a script which works but It waits for 30 mins even though log collection is complete before that. I have two issues with existing... (4 Replies)
Discussion started by: shunya
4 Replies

2. Shell Programming and Scripting

Difference between time stamp

Hi All i have a file data like below format A, B 2016-04-14 16:30:00,2016-04-14 16:31:17 2016-04-14 16:40:00,2016-04-14 16:41:10 2016-04-14 16:50:00,2016-04-14 16:50:41 2016-04-14 17:00:00,2016-04-14 17:00:35 2016-04-14 17:10:00,2016-04-14 17:11:48 2016-04-14 17:20:00,2016-04-14 17:20:37 i... (2 Replies)
Discussion started by: Tarak_nath
2 Replies

3. Shell Programming and Scripting

Logs between two time stamp

I am creating log monitoring script and stuck up to get the logs between two time stamp. can you please help me to create the script to get the logs between two time stamp, for example, I need the complete logs between # Time: 150328 1:30:10 and # Time: 150328 19:10:57 OS : Cent OS 6.x... (8 Replies)
Discussion started by: zenkarthi
8 Replies

4. Red Hat

collect red hat linux error logs

Hi, I have two questions,first of all is where can I collect more error logs(the log under /var/log/messages), also give the corresponding explain is grateful.The second one is the log under various versions(such as red hat,suse,etc) is the same or not. Thanks for answers. (1 Reply)
Discussion started by: zhaoyy
1 Replies

5. Solaris

System time and Cron time stamp not matching

On Solaris 10 server the system date won't match with the timestamp on files created by a cron jobs, Please help here is what i get when i check for system date infodba-ie10ux014:/tcpdv1_ie10/tcadmin/bin\n\r-> date Tue Apr 24 15:27:43 GMT 2012at same time i executed a cron job, and checked... (4 Replies)
Discussion started by: karghum
4 Replies

6. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

7. Shell Programming and Scripting

regarding time stamp

hi everyone i am facing a strange problem here suppose content of my file is a=1,2,3 b=2,3,4 c=4,5,6 time= now the problem is i want to add value in front of time variable and the value should be i format only "HHMMSS" so it should be like this a=1,2,3 b=2,3,4 c=4,5,6... (3 Replies)
Discussion started by: aishsimplesweet
3 Replies

8. Shell Programming and Scripting

How do i collect Date & Time from Different Directories in a script

How do i collect Date & Time from Different Directories in a script The script iam using for a single directory is : ls -l | grep awk '{print $8}' (2 Replies)
Discussion started by: laknar
2 Replies

9. Shell Programming and Scripting

How do i collect date and time for list of files in a directory

How do i collect date and time for list of files in a directory using AWK Command (4 Replies)
Discussion started by: laknar
4 Replies

10. UNIX for Dummies Questions & Answers

capturing the time stamp

Hi All, I am working on a korn shell script. i have a file such as: DS.PETSCO.20060601203514.20060531.ctl_20060717124431 i have 2 problems here. 1) i have to capture the time stamp from the above file i.e this number 20060717124431. format of time stamp is YYYYMMDDHHMMSS. can... (4 Replies)
Discussion started by: pavan_test
4 Replies
Login or Register to Ask a Question