Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Logfile check timestamp

$
0
0


I am trying to grab timestamps from a logfile to check if the process writing to the file is active and updating the file.
The file looks something like this and a timestamp is being generated in the first 19 char on the line but not on every line.
It is maximum gap of 10 lines without timestamp, and maximum 10 minutes of SQL processing without logfile update, so I can skip the year, month and date.

What is the best method for reading this long (30-50 MB) logfile from the end (like tail)
grab the last timestamp HH:mm:ss and compare with get-date -10 minutes giving an alarm if the process stops.


Logfile
..
2012.11.15 09:40:20 Information: Thread 0 SetFini........
2012.11.15 09:40:20 Information: Thread 0 SetFini........
at Module.ProcessDeadlinesManager.GetCachedPro........
at Module.ProcessDeadlinesManager.GetCachedPro........
at Module.WFServiceManager.ProcessDeadline(Tra........
at Module.WFServiceManager.ProcessActionData(W........
at Module.WFS ........
2012.11.15 09:40:27 Information: Oid 8e53cc2d-ce1........
..
..

I have tried different approaches without getting it right

Help appreciated

Knut Lyngstad


Viewing all articles
Browse latest Browse all 8583

Trending Articles