Kshell scripts and timing

Hello everyone,

I have a script thats acting funky, what I would like to do is report to a file, how long its taking to get to certain area's, in seconds. For example.

-- Start timer
-- Run unix command 1
-- Run unix command 2
-- Stop timer
-- Report Seconds
-- etc etc

Is there a way to do this, or am I really limited to time stamps and manually going through the reports?

time unix command1 && unix command2

Start with that - it will give time elapsed.

Thanks Jim I will take a look. I think my script might be too complicated for it though unless you can store the time result somewhere and continually add to it, but this is a good start and something to chew on.

From the KSH man page:

     SECONDS

           Each time this variable is referenced, the  number  of
           seconds  since  shell  invocation is returned. If this
           variable is assigned a value, then the value  returned
           upon  reference  will  be  the value that was assigned
           plus the number of seconds since the assignment.

Save the value of $SECONDS before your process starts and compare to $SECONDS once your process completes.