Search log for string and display hourly/daily report

Tim Chase python.list at tim.thechases.com
Wed Jan 23 15:08:19 EST 2013


On 01/23/13 13:05, spek06 at gmail.com wrote:
> I need to search a log file for a specific string (Successfully
> Sent) and report the number of instances in the last hour (from
> when executed) and total for the day so far (midnight till the
> time executed). Can anyone provide any examples of such a program
> or get me started?

You'd have to specify additional details on how the log-file is 
formatted, presumably how it's delimited, and what the format of the 
corresponding time-stamp is.  Something like

   "I have a tab-delimited log file where the 4th column is the 
timestamp in the format 'YYYY-MM-DD HH:mm:ss' and the 18th column is 
the status.  I want to search for items where the status contains 
'Successfully Sent' and then further filter them by (1) events in 
the last hour, and (2) all events today"

-tkc






More information about the Python-list mailing list