1833277 Members
3103 Online
110051 Solutions
New Discussion

Re: Execution Time

 
Prabhu_7
Frequent Advisor

Execution Time

Hi,

I execute 15 shell scripts from one main shell script. Main shell scripts writes log file for all other child scripts.

Now i need to include the start time (date,hours,mins and seconds) and end time
and total execution time of each script.

So when i open the main log file it should
say

OUTPUT of LOG.

Script1 started at 12/16/2003 11:30:23AM
x
y
z
Script1 Ended at 12/16/2003 11:45:23AM
Total Execution time 0 hrs 15 mins 0 seconds.

Any help?

Thanks
Raj

6 REPLIES 6
DIPAK KUMAR ROY
Frequent Advisor

Re: Execution Time

Try using "time" command for each script.

Thanks
Pete Randall
Outstanding Contributor

Re: Execution Time

Raj,

You could simply "echo `date` > LOG" at the start and end and use the "time" command to get the durations.


Pete

Pete
RAC_1
Honored Contributor

Re: Execution Time

at every scipt's start and end put something like this

echo "starting Execution at 1date1" >> /log_file

Echo "completed execution at `date`" >> /log_file

There is no substitute to HARDWORK
Helen French
Honored Contributor

Re: Execution Time

You can find the start and end times with 'date' command and the total execution time with 'timex' command:

#!/usr/bin/sh
echo "Script started at `date`"
timex script #grep the real time value here to TIME
echo "Script ended at `date`"
echo total time $TIME
Life is a promise, fulfill it!
john korterman
Honored Contributor

Re: Execution Time

Hi,
for the elapsed time in a script, try the SECONDS varable of the korn shell:

#!/usr/bin/sh
sleep 3
echo Total execution time: $SECONDS seconds

regards,
John K.
it would be nice if you always got a second chance
Prabhu_7
Frequent Advisor

Re: Execution Time

Can anyone give me a piece of code to do this? as i'm having very less time to code it.

Thanks a lot
Raj