Average completion time calculation?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Average completion time calculation?
# 1  
Old 05-20-2008
Question 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 sure there is an easy way to do this, as I would assume that I'm not the first person that would require info like this, but for now, it's beyond me.

Also, one potential problem that I haven't even tried to tackle yet is what happens when the jobs finishes at say, 23:40 one night, and then at 00:15 the next night. The method I've been trying to perfect will return something like 11:45 as the average (pretty much 12 hours off).

Last edited by Seawall; 05-20-2008 at 08:59 AM.. Reason: typo
# 2  
Old 05-20-2008
What do you mean by job completion time ? The time when a particular job was completed or time it took to complete a job ?
# 3  
Old 05-20-2008
Sorry if I was too vague.

By job completion time I mean the actual time that the job completed.

My end goal is to set up a script that will alert me if a job runs X minutes past its average. First step is to calculate the average.
# 4  
Old 05-20-2008
So if the job starts/started at exactly the same time every day whats stopping you from finding the avg of the above values? Just cut the first fields (use ':' as delimiter). Find the sum. Divide by 60 to find the total minutes. Add up second fields on each line delimited by ':'.
Add the aboves sums and divide my the number of lines to get the avg. Divide by 60 to get the avg time when your script should end.
# 5  
Old 05-20-2008
Quote:
Originally Posted by agn
What do you mean by job completion time ? The time when a particular job was completed or time it took to complete a job ?
Ah, that rings some bells with me.
I searched for my query before I posted the topic, and found several threads discussing how to figure the run time of a job.

Convert the time to seconds and subtract.

This should work for me too. Convert to minutes (HH*60+MM), add em all up, and divide by the # of values, then convert back to HH:MM.

However, that still will not work if a job finishes before midnight sometimes, and after midnight other times.

However, it is progress, and that is good.

I'll whip something up and post the code here to see if it can be improved upon, and to see if anyone has any ideas as to how to get around the midnight quandry.
# 6  
Old 05-20-2008
Quote:
Originally Posted by agn
So if the job starts/started at exactly the same time every day whats stopping you from finding the avg of the above values? Just cut the first fields (use ':' as delimiter). Find the sum. Divide by 60 to find the total minutes. Add up second fields on each line delimited by ':'.
Add the aboves sums and divide my the number of lines to get the avg. Divide by 60 to get the avg time when your script should end.
Very few of the jobs start at the same time every day, but that's not really important.

See my post above (after yours). Looks like we're on the same page now.
Thanks for your input.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with average calculation.

i have a file with 2 columns. i want to calculate the average of column 1 based on the values of column 2. here's how the file looks like. i want to calculate the sums of numbers corresponding to 1 and then calculate the average. same for numbers corresponding to zero. any help with a code would... (1 Reply)
Discussion started by: onerokeyz
1 Replies

2. Shell Programming and Scripting

Time calculation

Hi Gurus, I need to get one hour before time is yyyymmddhh format. ex. date +"%Y%m%d%H" gives 2017052814 but I need 2017052813 Thankx Please use CODE tags as required by forum rules! (6 Replies)
Discussion started by: nalakaatslt
6 Replies

3. Shell Programming and Scripting

Date time calculation

hello guys, I had been to many forums and many topics in this site as well for my question but did not get any solution. My question is how i can get y'day date with time stamp today is 20100729103819 and i am looking for output as 20100728103819. in simple words as we do in oracle sysdate-1... (4 Replies)
Discussion started by: lokaish23
4 Replies

4. Shell Programming and Scripting

Average calculation based on number of rows

Dear users, I need your support, I have a file like this: 272134.548 6680572.715 272134.545 6680572.711 272134.546 6680572.713 272134.548 6680572.706 272134.545 6680572.721 272134.543 6680572.710 272134.544 6680572.715 272134.543 6680572.705 272134.540 6680572.720 272134.544... (10 Replies)
Discussion started by: Gery
10 Replies

5. UNIX for Advanced & Expert Users

Completion time of a cron job ?

how can we identify the task completion time which was initiated by CRON. we have 1000 of jobs whihc are runing from cron so it is not feasable to edit every cron entry or every script to add the respective code to find teh completion time. Can some one please provide a inut to find the task... (3 Replies)
Discussion started by: NIMISH AGARWAL
3 Replies

6. Shell Programming and Scripting

Time stamp calculation

Hi all; I'm relatively new to scripting,I am working on a monitoring script.....where in i have to write subroutine which does the follows: It will check the time stamp of a file ( Oracle remarchive files) and compare it with existing time.If the time difference happen to be more than 90... (6 Replies)
Discussion started by: maverick_here
6 Replies

7. Shell Programming and Scripting

Calculating completion time

The date construct in UNIX can be used to calculate when something is finished: date -v+1H displays the time 1 hour from now. I want to use the same construct in a script, but it is leading to error messages: echo "Finished at: " `date -v+$durationH` where $duration is calculated based on input... (3 Replies)
Discussion started by: figaro
3 Replies

8. UNIX for Dummies Questions & Answers

Time Calculation

I have a file with over 100,000 lines of data with looking to compare times of about 2000 lines to get a total time of a process. The lines of unique data are as follows. FINER: CacSoapServer:reserveNetworkResource got the sessionID and INFO: Created CAC session ID The command... (5 Replies)
Discussion started by: bpfoster76
5 Replies

9. Shell Programming and Scripting

Time difference calculation

Hi Team, I am currently in the process of writing a script which will take a filename in the format SKADEV.0.db2.NODE0000.CATN0000.20080714231015.001 where the sixth string(with "." as the seperator) is the time stamp of the time of creation of the file. now here is my issue . I need to be... (2 Replies)
Discussion started by: Segwar
2 Replies

10. UNIX for Advanced & Expert Users

time calculation

Hi, I have start time as a string like 06:04:01 and end time like 06:05:01 i need do a simple math to get the duration. What is the best way to do this in Korn Shell scripting? Thanks (2 Replies)
Discussion started by: liux99
2 Replies
Login or Register to Ask a Question