Take minute per minute from a log awk

Hi, I've been trying to develop a script that performs the parsing of a log every 1 minute and then generating some statistics. I'm fairly new to programming and this is why I come to ask if I can lend a hand.

this is my log:

xxxx 16/04/2012 17:00:52 - xxxx714 - E234 - Time=       119 ms. 
xxxx 16/04/2012 17:00:52 - xxxx716 - A234 - Time=       144 ms. 
xxxx 16/04/2012 17:00:52 - xxxx731 - A323 - Time=        80 ms. 
xxxx 16/04/2012 17:00:52 - xxxx733 - A234 - Time=        90 ms. 
xxxx 16/04/2012 17:00:53 - xxxx735 - A234 - Time=        91 ms. 
xxxx 16/04/2012 17:00:53 - xxxx736 - A234 - Time=        89 ms. 
xxxx 16/04/2012 17:00:53 - xxxx738 - A234 - Time=        82 ms. 
xxxx 16/04/2012 17:00:53 - xxxx739 - R234 - Time=       127 ms. 
xxxx 16/04/2012 17:00:53 - xxxx746 - R234 - Time=        37 ms. 
xxxx 16/04/2012 17:00:53 - xxxx743 - E234 - Time=       176 ms. 
xxxx 16/04/2012 17:00:53 - xxxx744 - R234 - Time=       188 ms. 
xxxx 16/04/2012 17:00:53 - xxxx748 - A234 - Time=        37 ms. 
xxxx 16/04/2012 17:00:53 - xxxx751 - A234 - Time=        61 ms.

I would just like to take on a cron every minute and then generate the statistics (the statistics awk armed I have it) but I need this to give a range of times.

Thanks for your help!

Best Regards!

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

So the next time awk is run, it should start processing from where it left off before? Or do you want the logfile cleared every time awk is run? or what?

need clean log but every 1 minute because I have another script for statistics armed with this format. Like a cat file | grep x > greped but taking the time especified

Thanks for the immediate response and apologize for the above

So every minute, you want to select for the next minute range of time from a long logfile?

Actually yes, but as it runs Through The cron every minute, would need only the current minute, that is, which just happened

Thanks

---------- Post updated at 12:14 PM ---------- Previous update was at 02:57 AM ----------

hi guys, any idea of how to make it? im :wall:! jaja Please any help for a pour man whitout awk aknowledgement!

Regards

I'm still having a hard time figuring out what you actually want. Sometimes you imply the logfile is continuous. Sometimes you imply it's cleared every minute. Sometimes you imply there are several logfiles.

How about you show the exact input you have, the exact output you want, and some pseudocode about how one is derived from the other.

1 Like

Hi Corona, really i want some like:

awk -v start="$(date -d '1 mins ago' + '%b %d %T') -v end="$(date +'%b %d %T')" '{tm=$1" "$2" "$3}; start<tm&&tm<end' /path/to/log.log

but, i need it, for a output like before show:

xxxx 16/04/2012 17:00:53 - xxxx751 - A234 - Time=        61 ms.

---------- Post updated at 06:38 PM ---------- Previous update was at 02:25 PM ----------

maybe im not expressing better way, the parse will extract from the log the complete log generated in the las minute example:

$date
$Fri Apr 20 18:09:00 GRNLNDST 2012

So the awk will take the values between the 18:08:00 to 18:09:00,

It's asigned to cron, and for this reason the script here just will take the complete log at the minute them put the output on file.

greetings

If you can arrange the dates in YYYY MM DD HH MM SS order, they will sort alphabetically. So it's a matter of reordering:

awk -v start="$(date -d '1 mins ago' +'%Y %m %d %H:%M:%S') -v end="$(date +'%Y %m %d %H:%M:%S')" '{split($1, D, "/"); tm=D[3]" "D[2]" "D[1] " " $2}; start<tm&&tm<end' /path/to/log.log