Help with Calculating time difference between many directories in UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Help with Calculating time difference between many directories in UNIX
# 1  
Old 03-13-2012
Help with Calculating time difference between many directories in UNIX

A report needs to come some what similar to this

No of elements Stream Batch No Load time


A B C D

A,B,C im able to get quite easily
Code:
wc -l /usr/local/intranet/areas/prod/output/SRGW_0?/*/MESSAGE_T.dat

O/P of above command.
Code:
A B C 
75/usr/local/intranet/areas/prod/output/SRGW_05/153907/MESSAGE_T.dat
26 /usr/local/intranet/areas/prod/output/SRGW_05/153908/MESSAGE_T.dat
110 /usr/local/intranet/areas/prod/output/SRGW_05/153909/MESSAGE_T.dat

Code:
wc -l /usr/local/intranet/areas/prod/output/SRGW_05/*/MESSAGE_T.dat | cut -f1,8,9 -d"/"

O/P of above command.
Code:
159 /SRGW_05/153917
367 /SRGW_05/153918
21 /SRGW_05/153919
12 /SRGW_05/153920
88 /SRGW_05/153921
35 /SRGW_05/153922
36 /SRGW_05/153923

For D I need to check every 2 Batches and compare so I need to put it in a loop

Load time needs to be time stamp of folder created of C.
Code:
ls -lrt /usr/local/intranet/areas/prod/output/SRGW_0?/

O/P of above command.
Code:
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 10:44 153913
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 10:48 153914
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 10:53 153915
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 10:57 153916
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 11:01 153917
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 11:05 153918
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 11:10 153919
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 11:14 153921
drwxr-xr-x 2 mtsadm mts 4096 Mar 13 11:14 153920
 
Load time of 153913 = 4 minutes.

I need to in corporate a logic similar to this but need to do it in a loop as there are many directories for load time calculation.

Store in a variable = ls -lrt /usr/local/intranet/areas/prod/output/SRGW_05/ | cut -f24 -d" "
Code:
h1=`echo $T1|cut -d: -f1`
m1=`echo $T1|cut -d: -f2`
x1=`echo "$h1*60 + $m1"|bc -l`
 
h2=`echo $T2|cut -d: -f1`
m2=`echo $T2|cut -d: -f2`
 
x2=`echo "$h2*60 + $m2"|bc -l`
 
if test $x1 -lt $x2
then
diff=`echo "$x2 - $x1"|bc -l`
else
diff=`echo "$x1 - $x2"|bc -l`
fi
 
echo "Load time is $diff"

Entire O/p should be like this eventually

Code:
 
No of elements Stream Batch No Load time
 
 
A B C D

Can some one help me ?

Moderator's Comments:
Mod Comment PLEASE USE code tags -- I had to reformat the entire post


My OS is AIX

Last edited by Scott; 04-04-2012 at 08:26 AM.. Reason: jim mcnamara: Reformat completely; Scott: removed pointless poll
# 2  
Old 03-13-2012
Calculating load time

Appologies

Last edited by peckenson; 03-14-2012 at 02:30 AM.. Reason: double thread merged
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calculating Time difference Between two Rows in Linux

16:45:51 10051 77845 16:45:51 10051 77845 16:46:52 10051 77846 16:46:53 10051 77846 Match the last PID then subtract second line time with first line. Please help me with any command or script. working in media company on a project OS: RHEl7 tried command: awk 'function... (2 Replies)
Discussion started by: vivekn
2 Replies

2. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

3. Shell Programming and Scripting

Difference Time Unix Shell

I have 2 variables MTIME="Jan_2_2012_23:55:49" SCH_TIME="Jan_03_2012_00:32:28" I want to find the time taken (in seconds) between MTIME and SCH_TIME. Is there any way by which this can be done in Unix Shell Script? (4 Replies)
Discussion started by: ankitncr
4 Replies

4. Shell Programming and Scripting

Find Time difference in Unix

Hi, START_TIME :- "10-NOV-2009 00:00:04" STOP_TIME :- "10-NOV-2009 00:05:47" Please help to find difference between these two. Searched for the same topic but did not find an answer for the same time format :( Regards, Robin (3 Replies)
Discussion started by: robinbannis
3 Replies

5. Shell Programming and Scripting

Calculating the difference between dates

Hello! i need to find files lower and bigger that one date i pass, i search in the man find, but i didn't find anything, the only that i find is the parameter -mtime, in this parameter i can pass a number of days, but i need to know the difference between dates, any built-in function for do... (15 Replies)
Discussion started by: claw82
15 Replies

6. Shell Programming and Scripting

Time difference in Minute in UNIX

is there any ways to get the time difference between 2 dates in UNIX? for example, For below date the outut should come 22 minutes startdate enddate ========= ======= 06/17/2008 13:25 06/17/2008 13:47 For, below date, the output should come 1462 minutes ... (5 Replies)
Discussion started by: Amit.Sagpariya
5 Replies

7. Shell Programming and Scripting

parsing and calculating difference.

Hi, I have a file with the contents as following Access Time: Thu Nov 6 16:43:45 2008 Modify Time: Thu Nov 6 16:43:45 2008 Change Time: Thu Nov 6 16:43:45 2008 Access Time: Thu Nov 6 16:43:02 2008 Modify Time: Thu Nov 6 16:44:01 2008 Change Time: Thu Nov 6 16:44:01 2008 I need... (3 Replies)
Discussion started by: meetmano143
3 Replies

8. Shell Programming and Scripting

Time Difference between two files in two different directories

Hi, Can anyone please help me. How to write shell script for taking time difference between two files which are in two different folders. Example: Folder1 is having sample_1_*.txt with the time 13:10 hours Folder2 is having sample_1_*.txt with the time 13:17 hours Now i need the time... (6 Replies)
Discussion started by: SanjayPasum
6 Replies

9. Shell Programming and Scripting

calculating the time difference, when the script was executed and the currenent file

Hi, I has created the shell script in HP_UX 11.23 and using the command, echo $(date +%Y%m%d%H%M%S) > $DIR/alert, placing the time of running the script into a file alert. I want to compare the time in the above file alert with the current time.If difference is more than 5 min, then print the... (7 Replies)
Discussion started by: velocitnitin
7 Replies

10. Shell Programming and Scripting

Unix function to calcuate the difference in time

HI , I need to get the timedifference between two values... which funcation will help eg: difference betweem 19:22 and 19:43 should give 21 mins (2 Replies)
Discussion started by: savitha
2 Replies
Login or Register to Ask a Question