Visit Our UNIX and Linux User Community


Find execution time of script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find execution time of script
# 1  
Old 07-02-2013
Find execution time of script

i am using bash


Code:
 
START=$(date +%s)
 

 END=$(date +%s)
 
 
DIFF=$(echo "$END - $START" )

this code is not working
# 2  
Old 07-02-2013
Already many posts here on this topic

Please try a search of the forum prior to submitting questions.

https://www.unix.com/shell-programmin...tatistics.html
# 3  
Old 07-02-2013
Quote:
Originally Posted by joeyg
Please try a search of the forum prior to submitting questions.

https://www.unix.com/shell-programmin...tatistics.html
those methods are notr working
# 4  
Old 07-02-2013
Quote:
Originally Posted by rafa_fed2
those methods are notr working
Your answer does not help at all! What do you mean by "not working".

Can you be more specific? Post what all issues that you are facing.
# 5  
Old 07-02-2013
You need to calculate the difference of the two numbers, not simply print them.

i.e.

Code:
DIFF=$((END - START))

exactly as shown in the post linked to by joeyg.

Which OS are you using?
# 6  
Old 07-02-2013
Quote:
Originally Posted by Yoda
Your answer does not help at all! What do you mean by "not working".

Can you be more specific? Post what all issues that you are facing.
t_1.sh
Code:
START=$(date +%s)


 END=$(date +%s)


DIFF=$(echo "$END - $START" )
echo $DIFF

i execute the t_1.sh
and getting the output as %s - %s
# 7  
Old 07-02-2013
If you're using Solaris, %s does not work. You can try Perl:

Code:
START=$(perl -e 'print time();')


Previous Thread | Next Thread
Test Your Knowledge in Computers #982
Difficulty: Medium
NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To take script execution time

Hello Guys, I would like to know is there a way to take the script execution time For e.g i am having a script.sh i need to write inside he script.sh like Start time : 10-Mar-2016 02:30:35 all code over here ... End time : 10-Mar-2016 03:30:32 Script start time - 02:30:35 ... (7 Replies)
Discussion started by: Master_Mind
7 Replies

2. Shell Programming and Scripting

Optimizing script to reduce execution time

AFILENAME=glow.sh FILENAME="/${AFILENAME}" WIDTHA=$(echo ${FILENAME} | wc -c) NTIME=0 RESULTS=$(for eachletter in $(echo ${FILENAME} | fold -w 1) do WIDTHTIMES=$(awk "BEGIN{printf... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. HP-UX

Script execution is very slow when trying to find all files and their owners on HP-UX box

Hi, I have a HP-UX server were I need to list all the files in the entire file system, their directory path, last modified date, owner and group. I do not need to search the file contents. I created the script given below and I am excluding directories and files of type tmp, temp and log. The... (4 Replies)
Discussion started by: Adyan Faruqi
4 Replies

4. Shell Programming and Scripting

what would a script include to find CPU's %system time high and user time high?

Hi , I am trying to :wall: my head while scripting ..I am really new to this stuff , never did it before :( . how to find cpu's system high time and user time high in a script?? thanks , help would be appreciated ! :) (9 Replies)
Discussion started by: sushwey
9 Replies

5. Shell Programming and Scripting

execution time / runtime -- bash script please help!

Hello, I'm running a bash script and I'd like to get more accurate a runtime information then now. So far I've been using this method: STARTM=`date -u "+%s"` ......... *script function.... ......... STOPM=`date -u "+%s"` RUNTIMEM=`expr $STOPM - $STARTM` if (($RUNTIMEM>59)); then... (6 Replies)
Discussion started by: TehOne
6 Replies

6. UNIX for Dummies Questions & Answers

script start and end of execution of time

Hi All, Can we get to know the start time and end time of execution of a script? (This script doesn't write any logs.) I mean, is there any built in process logs to track these records? (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

7. Shell Programming and Scripting

get execution time of a script

Hi, I have a simple question. How can I get the execution time of a script and maybe put it in a variable? Another question. How can I get only time and not date and put it in a variable? I tried something with "date" command but with no success... If someone could help me... (8 Replies)
Discussion started by: Moumou
8 Replies

8. Shell Programming and Scripting

How to find the time taken for a script to run?

I have just written a Csh script and i want to find out how long does the script take to complete executing. Is there any codes which i can put into my script to capture its run time ? (9 Replies)
Discussion started by: Raynon
9 Replies

9. Shell Programming and Scripting

time of execution of script

i want to test whether a script has been executed in last 15 days or not....please help how can i do this...is there any copmmand there to know timings of last execution of any script (8 Replies)
Discussion started by: arghya_owen
8 Replies

10. Shell Programming and Scripting

script execution time calculation

I am writting a script in the ksh shell and am trying to find a way to report the total execution time of the script without requiring the user to specify the time function when executing the script. Does anyone have any examples they have used. I have been setting up two date variables (one at... (9 Replies)
Discussion started by: johnsonbryce
9 Replies

Featured Tech Videos