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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find the time taken for a script to run?
# 1  
Old 09-18-2006
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 ?
# 2  
Old 09-18-2006
check time command.ksh provide builtin variable SECONDS.not sure about csh.
# 3  
Old 09-18-2006
you can capture begin time and end time. and then calculate execution time =)
# 4  
Old 09-18-2006
Quote:
Originally Posted by mercy
you can capture begin time and end time. and then calculate execution time =)
I tried. See below. Both output of start and end time is identical. The runtime for the script actually lasted for few mins and not negligible! Pls help .Thanks

set time_start = `date '+%T%t%d_%h_06'`
set time_end = `date '+%T%t%d_%h_06'`

echo "$time_start"

BODY OF SCRIPT

echo "$time_end"
# 5  
Old 09-18-2006
you mast set time_end after ending of script body.
for example
Code:
#!/bin/sh
time_start=`date '+%T%t%d_%h_06'`
echo "$time_start"

script body

time_end=`date '+%T%t%d_%h_06'`
echo "$time_end"

# 6  
Old 09-18-2006
Quote:
Originally Posted by mercy
you mast set time_end after ending of script body.
for example
Code:
#!/bin/sh
time_start=`date '+%T%t%d_%h_06'`
echo "$time_start"

script body

time_end=`date '+%T%t%d_%h_06'`
echo "$time_end"

Oh i got it! Thanks.. but is there any code which i can use to find the difference between the 2 time ?
# 7  
Old 09-18-2006
time_start=`date +%s`

script body

time_end=`date +%s`
time_exec=`expr $(( $time_end - $time_start ))`

echo "Execution time is $time_exec seconds"
This User Gave Thanks to mercy For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to run in given time

Hi All, Would like to write a Script which will run between 11am to 3 pm and send the results to output.txt. Please suggest. (2 Replies)
Discussion started by: vasuvv
2 Replies

2. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

3. Shell Programming and Scripting

Run a task in a script at a particular time

I have an ETL process that triggers a shell script. This script picks the files created by the ETL process and does an SFTP. These are huge files. Due to infrastructure limitations, we need to trigger the actual SFTP part only during the 2nd, 16th, 31st and 46th minute of an hour. Please let me... (2 Replies)
Discussion started by: vskr72
2 Replies

4. Shell Programming and Scripting

Time taken to run a SQL script

Hello I am asked to run around 5-6 SQL queries in a shell script and take a note of the time taken to execute each query to a file. How do I get the time taken to run the individual SQL queries (2 Replies)
Discussion started by: vat1kor
2 Replies

5. Shell Programming and Scripting

Shell script to find the run time based on log entries?

Shell script to find the run time based on log entries? Below is the log files content updated when the script test.sh runs. I would like to calculte the difference between first update time stamp and last update time stamp to find the run time of the script. The below log file shows the first... (1 Reply)
Discussion started by: mailtopranesh
1 Replies

6. Shell Programming and Scripting

last run time of any script

how to find when last time a scrit has ran? (7 Replies)
Discussion started by: RahulJoshi
7 Replies

7. Shell Programming and Scripting

run script for given time

Hi! I need to run my script for a specific number of time, as specified by the user: For instance, if the user specified 10, my script should run for until 10 seconds expire. How do I do this? (0 Replies)
Discussion started by: looza
0 Replies

8. Shell Programming and Scripting

Run script at same time

Hi My five script run throgh crontab at same time at 6 clock. Due to problem in the data load .Now I want to check time of load finish run these jobs. I create a script which check the load finish time but I have no idea how I run these JObs. This is very urget to me. Please reply me as soon... (3 Replies)
Discussion started by: Jamil Qadir
3 Replies

9. UNIX for Advanced & Expert Users

run script in autosys at a specified time.

I have created a shell script. I want to run the script in Autosys. Please note my shell script runs as "$ ksh run.ksh" How do I make autosys run this script at 5:00PM every day? insert_job: abc job_type: c box_name: run.box command: ksh run.ksh machine: mach1 #owner: mach1@mymach... (1 Reply)
Discussion started by: gram77
1 Replies

10. UNIX for Advanced & Expert Users

Preventing script to run at the same time.

I have a script, myscript.pl I want to set the script to exit if it is already running. At the moment I am using soft stop. eg: if -e dummy file then exit else create a dummy file Is there any other better way to perform this? Maybe ps -ef | egrep 'myscript.pl' (3 Replies)
Discussion started by: cronboss
3 Replies
Login or Register to Ask a Question