Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7003879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:07:35+00:00 2026-05-27T21:07:35+00:00

My apologies if this is too basic. I’m really not looking for someone to

  • 0

My apologies if this is too basic. I’m really not looking for someone to do the work but rather point me in the right direction. I have a log files going back several years that I want to pull information out to determine how long something is taking to look for patterns on when performance is slow. I am able to read each line but cannot read the previous line to get its time.

The Log files are as follows:

~
Other Stuff
~
12/21/11 18:58:15 Inserting data into ST_ITEMS
ST_ITEMS Row: 10000 inserted at 12/21/11 19:40:06
ST_ITEMS Row: 20000 inserted at 12/21/11 20:05:58
ST_ITEMS Row: 30000 inserted at 12/21/11 20:37:03
ST_ITEMS Row: 40000 inserted at 12/21/11 20:59:25
ST_ITEMS Row: 50000 inserted at 12/21/11 21:17:43
ST_ITEMS Row: 60000 inserted at 12/21/11 21:54:47
12/21/11 21:59:24 Finished inserting data into  Staging Tables

~
Other Stuff
~

12/21/11 22:04:43 Inserting data into ST_ITEMS
ST_ITEMS Row: 10000 inserted at 12/21/11 22:38:53
ST_ITEMS Row: 20000 inserted at 12/21/11 23:06:33
ST_ITEMS Row: 30000 inserted at 12/21/11 23:33:03
ST_ITEMS Row: 40000 inserted at 12/22/11 00:05:38
ST_ITEMS Row: 50000 inserted at 12/22/11 00:45:59
ST_ITEMS Row: 60000 inserted at 12/22/11 01:12:42
ST_ITEMS Row: 70000 inserted at 12/22/11 01:40:02
ST_ITEMS Row: 80000 inserted at 12/22/11 02:14:23
ST_ITEMS Row: 90000 inserted at 12/22/11 03:04:15
ST_ITEMS Row: 100000 inserted at 12/22/11 03:47:13
ST_ITEMS Row: 110000 inserted at 12/22/11 04:36:21
ST_ITEMS Row: 120000 inserted at 12/22/11 05:44:47
ST_ITEMS Row: 130000 inserted at 12/22/11 06:28:24
ST_ITEMS Row: 140000 inserted at 12/22/11 07:10:55
ST_ITEMS Row: 150000 inserted at 12/22/11 07:35:16
12/22/11 07:40:28 Finished inserting data into  Staging Tables

~
Other Stuff
~

Essentially, I want to calculate how long each 10000 rows take by subtracting the date/time of a line from the one above it. I’m looking at both Perl and Bash as options but it seems that Perl offers more possibilities.

PERL
#!/usr/bin/perl

use strict;
use warnings;

use Date::Parse;
use Date::Format;

my $start = "2007-11-17 12:50:22";
my $stop  = "2007-11-17 12:53:22";
my $diff  = str2time($stop) - str2time($start);

#printf "diff between %s and %s is %d seconds\n", $start, $stop, $diff;

open(LOG,"info_refresh_tvl.log.122111_185800") or die "Unable to open logfile:$!\n";
while(my $line = <LOG>){


        if ($line=~/inserted\b/)

        {
        #Pseudocode  
            #Parse time from Pervious Line
            #Parse time from Current Line
            #Calculate Difference of Time
                    #my $diff  = str2time($stop) - str2time($start);
            #printf "diff between %s and %s is %d seconds\n", $start, $stop,     $diff; ')

            printf $line ;


        }

}
close(LOG);

BASH

grep 'ST_ITEMS Row:' logfile122111.log | while read line
   do
        event=$(echo "$line" | awk '{print $6 " " $7}')

       case $event in
          "10000")
                ;;
          *)
                past=$(echo "$line" | awk '{print $6 " " $7}')
                current=$(echo "$line" | awk '{print $6 " " $7}'
                echo $past
                echo $current)
                ;;
       esac



echo $event


   done
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:07:36+00:00Added an answer on May 27, 2026 at 9:07 pm

    Just save each line when you continue after the comparison. Overwrite it with the current line after you’re done.

    In pseudocode:

    $CurrentLine = $line;
    #Parse time from $CurrentLine
    #Parse time from $LastLine
    #Calculate difference of time
    $LastLine = $line;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this is a too basic question but I couldn't find any satisfactory
Apologies if this is too abstract, but hopefully someone can help. I have a
Apologies if this is a slightly noob question, but looking to clarify my thoughts
First, apologies,this should be simple but I've had too much coffee and cannot wrap
I apologize if this question is too basic, but I just can't figure out
I've tried to Google for this but maybe I'm not forming my query right,
Apologies if this is too ignorant a question or has been asked before. A
Apologies if this is a repost, I could not find the search terms to
Apologies if this was already asked but, I have had a look and can't
Apologies if this is a silly question, and I'm not even sure of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.