The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Run script at same time Jamil Qadir Shell Programming and Scripting 3 03-07-2008 12:00 PM
run script in autosys at a specified time. gram77 UNIX for Advanced & Expert Users 1 03-06-2008 02:24 PM
Preventing script to run at the same time. cronboss UNIX for Advanced & Expert Users 3 11-26-2007 10:48 AM
First time help, please - checksum script... kapolani Shell Programming and Scripting 6 10-06-2004 09:22 AM
Please Help ( Calculate time taken in a script) sanjay92 UNIX for Dummies Questions & Answers 9 10-02-2001 11:20 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-14-2004
encrypted's Avatar
Registered User
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 218
time take by a script

Hi !

I have got a script which takes some time to execute.
Eg. if the script is called test.sh

#!/bin/bash
<command1 to execute>
<command2 to execute>
<command3 to execute>
<command4 to execute>
.
.
.
.
<command n to execute>

At the end of the script I want to show the users the actual time(user NOT CPU) taken for the script to execute. I know of the time
command but where shall I put in the code for calculating the time.
Reply With Quote
Forum Sponsor
  #2  
Old 07-14-2004
s93366's Avatar
Registered User
 

Join Date: Apr 2002
Location: Sweden
Posts: 159
Hi..

A solution would be to use test.sh to time another shell script with the acctual commands..
---
test.sh
#!/bin/sh
time /path/to/script/sh

---

/Peter
Reply With Quote
  #3  
Old 07-14-2004
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Code:
#!/bin/ksh

time ( command1 && \
           command2 && \
           command3 && \
           commandn )

exit 0
For some reason this won't work with bash nor sh. It works fine and dandy with ksh though.

Peter's solution above is guaranteed to work on all shells so is the solution I'd personally go for.

Ta,
ZB
Reply With Quote
  #4  
Old 07-14-2004
encrypted's Avatar
Registered User
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 218
Thanks Peter!

I was expecting a similar solution.

Cheers
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0