Visit Our UNIX and Linux User Community


Average Time


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Average Time
# 1  
Old 01-16-2008
Java Average Time

Hi Guys,
I am using a command

$ runprt_req PPGUS_ROYXN1102
Output:
**************** Start Date and Time End Date and Time***
PPGUS_ROYXN1102 01/15/2008 02:20:08 01/15/2008 04:54:50
PPGUS_ROYXN1102 01/12/2008 02:03:57 01/12/2008 04:22:10
PPGUS_ROYXN1102 01/11/2008 02:07:55 01/11/2008 04:28:54
PPGUS_ROYXN1102 01/10/2008 03:13:57 01/10/2008 04:52:24

I need to find the average time between Start and End Time
Ex: 02:20:08 - 04:54:50 So the average time is 02:34:02

Similarly i need the average time for the all the columns
Ex:
Start Time End Time Average Time
02:30 02:40 00:10
03:30 03:30 00:00
...........
I have a very big output, so its difficult to find the average time easily.
It will be helpfull for me, if i get a command or a script.
I tried using awk command, but i not much familiar with unix, so i didnt get any output except Syntax ErrorSmilie
Thanks in Advance.
# 2  
Old 01-16-2008
Code:
#!/bin/sh
awk 'NR>1{
        n=split($3,starttime,":")
        m=split($NF,endtime,":")
        s_hr=starttime[1]
        s_min=starttime[2]
        s_ss=starttime[3]
        e_hr=endtime[1]
        e_min=endtime[2]
        e_ss=endtime[3]
        stime = (s_hr * 60 * 60) + (s_min * 60) + s_ss
        etime = (e_hr * 60 * 60) + (e_min * 60) + e_ss
        timedifference = etime - stime
        print timedifference " secs"
        # I leave to you to calculate back the average time in hr:min:sec
        # hint: take timedifference divide by 3600 to get hr. convert the remainder to min and secs

}
' "file"

 

Previous Thread | Next Thread
Test Your Knowledge in Computers #984
Difficulty: Medium
FreeBSD was the most popular open-source BSD operating system, accounting for more than three-quarters of all installed BSD systems.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to count average and max respon time?

sorry i will revise first (1 Reply)
Discussion started by: fajar_3t3
1 Replies

2. UNIX for Dummies Questions & Answers

How to chnage format and subtract time and date and get average.?

Hello All , Please support for below request how to change format and subtract time and date and get average. xxx 13-OCT-15 11.32.18.241000 AM 13-OCT-15 11.35.49.089080 AM xxx 13-OCT-15 11.32.24.000000 AM 13-OCT-15 11.45.17.810904 AM xxx 13-OCT-15 11.32.25.232000 AM ... (1 Reply)
Discussion started by: mirwasim
1 Replies

3. Shell Programming and Scripting

Need to get average idle time using mpstat

I want to get average idle time of the server using mpstat. The problem I am having is %idle is not in same columns in all the versions of linux. example 1: example 2: I tried below command as generalized solution but as Average as one less column output is not proper. I am... (1 Reply)
Discussion started by: kumarjohn
1 Replies

4. Shell Programming and Scripting

Calculate Average time of one column

Hello dears, I have a log file with records like below and want to get a average of one column based on the search of one specific keyword. 2015-02-07 08:15:28 10.102.51.100 10.112.55.101 "kevin.c" POST ... (2 Replies)
Discussion started by: Newman
2 Replies

5. Shell Programming and Scripting

Calculate average time using a script

Hello, I'm hoping to get some help on calculating an average time from a list of times (hour:minute:second). Here's what my list looks like right now, it will grow (I can get the full date or change the formatting of this as well): 07:55:31 09:42:00 08:09:02 09:15:23 09:27:45 09:49:26... (4 Replies)
Discussion started by: jaredhanks
4 Replies

6. UNIX for Dummies Questions & Answers

Determining load average over a period of time

How can i determine the load average of a centos server for the last 1 hour? (3 Replies)
Discussion started by: proactiveaditya
3 Replies

7. UNIX for Dummies Questions & Answers

Average in awk based on time

Hi I am looking for an awk script which can compute the average of the last column based on the date and time. The file looks: site1,"2000-01-01 00:00:00", "2000-01-01 00:59:00",0.013 site2,"2000-02-01 01:00:00", "2000-02-01 01:59:00",0.035 site1,"2000-02-01 02:00:00", "2000-02-01... (15 Replies)
Discussion started by: kathy wang
15 Replies

8. UNIX for Dummies Questions & Answers

Average completion time calculation?

I've been trying all night to come up with a script that will take a file that contains job completion times like this as input: 18:30 17:45 16:39 18:01 17:50 ... and figure the Average completion time. I've tried several things, and I just can't seem to get it to figure correctly. I'm... (5 Replies)
Discussion started by: Seawall
5 Replies

9. Shell Programming and Scripting

average transaction time

Hi all, I have large daily log file(s) that hold the times for requests and responses on different system requests. What I want to do is work out average transaction times for the day (one log = one day). The problem I'm having is figuring out how to skip rows, i've sorted the output by uniq... (2 Replies)
Discussion started by: nhatch
2 Replies

10. UNIX Desktop Questions & Answers

How to find no of occurances Finding average time?

Hi, I have MyLog.log file, and it contains "*** response Time 150", I want to develop Unix script like , 1. extract all such occurances in the MyLog.log file and 2. compute the average time taken I am new to Unix, any one can give any idea/sample code for this? Thanks in advance. (1 Reply)
Discussion started by: redlotus72
1 Replies

Featured Tech Videos