I need to calculate time difference between two log messages of /var/log/messages. As we know log messages prefixed by date & time , i want time difference between two log entries.
feedback
|
|
I've chosen the first and last messages in
| |||
|
feedback
|
|
In bash, once you figure out what date/times you want to use you can write
Which will give you number of seconds between those two times. If you want to automate finding firsttime and secondtime, you're going to have to tell us what exactly you're looking for in the log. | |||
|
feedback
|
|
I assume you want to find the largest time gap between two consecutive log messages. If so, see below for a script that should do the trick. I wrote this script a couple of years ago to print out a particular time range from the messages file, and it was pretty easy to customize:
| |||
|
feedback
|