Shell Script Statistics


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Statistics
# 1  
Old 12-09-2011
Power Shell Script Statistics

Hi All,

I am writing a UNIX shell script for the Database Operations and wanted to take the statistics i.e. How much time my script has taken to complete the operation.

I wanted to apply the logic say: In the beginning of the script I will store the value of current date and time in some variable and then finally I will take the difference of that datetime variable from the current date and time.

I am very new to shell scripting. Can some one help me to put this logic into the shell script code.

Let me know if any new logic will hold good for my requirments.

Last edited by ambarginni; 12-09-2011 at 07:19 AM.. Reason: not clear
# 2  
Old 12-09-2011
use time command

Code:
 
$time yourscript.sh

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 12-09-2011
Code:
$ time ./script.sh
or
$ time sh script.sh

This User Gave Thanks to balajesuri For This Post:
# 4  
Old 12-09-2011
I want to write this statistics into a log file (writing logs through the same script).... When I used the above suggestions in my script it says can't execute the script.sh Smilie
# 5  
Old 12-09-2011
Code:
#! /bin/bash

start=`date +%s%N`

echo "hello"
sleep 1
echo "world"
sleep 1

end=`date +%s%N`
dif=$(($end - $start))

echo "Execution time in nanoseconds: $dif"

You can do an appropriate conversion to seconds using the bench calculator.
This User Gave Thanks to balajesuri For This Post:
# 6  
Old 12-12-2011
Thanks balajesuri

It Worked for me....

Thanks Again
Ambar Agrawal
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need optimized awk/perl/shell to give the statistics for the Large delimited file

I have a file size is around 24 G with 14 columns, delimiter with "|" My requirement- can anyone provide me the fastest and best to get the below results Number of records of the file First column and second Column- Unique counts Thanks for your time Karti ------ Post updated at... (3 Replies)
Discussion started by: kartikirans
3 Replies

2. Shell Programming and Scripting

Shell scripting: frequency of specific word in a string and statistics

Hello friends, I need a BIG help from UNIX collective intelligence: I have a CSV file like this: VALUE,TIMESTAMP,TEXT 1,Sun May 05 16:13:05 +0000 2013,"RT @gracecheree: Praying God sends me a really great man one day. Gotta trust in his timing. 0,Sun May 05 16:13:05 +0000 2013,@sendi__... (19 Replies)
Discussion started by: kraterions
19 Replies

3. Shell Programming and Scripting

awk based script to print the "mode(statistics term)" for each column in a data file

Hi All, Thanks all for the continued support so far. Today, I need to find the most occurring string/number(also called mode in statistics terminology) for each column in a data file (.csv type). For one column of data(1.txt) like below Sample 1 2 2 3 4 1 1 1 2 I can find the mode... (6 Replies)
Discussion started by: ks_reddy
6 Replies

4. Shell Programming and Scripting

statistics using awk

Hi, I have 3 columns in a file listed below. X Y X/(X+Y) 1 1 0.5 1 1 0.5 4 1 0.8 1 1 0.5 6 1 0.857142857 1 1 0.5 23 1 0.958333333 Now I want to find confidence interval using the formula for each row. (p-2 sqrt p(1-p)/(x+y), p+2... (7 Replies)
Discussion started by: Diya123
7 Replies

5. Shell Programming and Scripting

Shell Runtime Statistics

Hi, I am trying to capture runtime stats of a shell script (c shell). Are there system variables to call? Or should I create a date variable at the start of the script and at the end of the script? I am trying to capture the time if the script stops or ends with error. Please help. ... (4 Replies)
Discussion started by: CKT_newbie88
4 Replies

6. UNIX for Advanced & Expert Users

Getting Socket statistics

Is there any way to get the file descriptor statistics of a socket file descriptor? I know that the fstat, stat system calls are for this purpose, but I want to know it there any way to get socket connection statistics for a file descriptor(like socket flags, connection type etc). Does /proc... (3 Replies)
Discussion started by: comp_wizard07
3 Replies

7. Shell Programming and Scripting

Analyze Statistics

I have a file which contains records in the format of 2006-08-25 12:06:13|ABC|93 2006-08-25 12:45:55|ABC|203 2006-08-25 01:48:19|DEF|156 2006-08-25 01:49:09|ABC|12798 2006-08-25 02:49:59|GHL|4109 2006-08-25 03:50:50|DEF|234 where the format is "arrive time"|"message type"|"processing... (3 Replies)
Discussion started by: mpang_
3 Replies

8. Programming

system statistics

i am currently using c functions such as getprocs and statsfs to obtain process information and filesystem information on machines running aix 4.3.3.0. (soon to be running aix5.1) is there a function available to access information similar to the information provided by a vmstat command? i also... (1 Reply)
Discussion started by: briansmith40
1 Replies
Login or Register to Ask a Question