Total time taken

Hi Friend,
Need your help.
I have a file which has information of start time and End time . I need to find how much time takes to complete the job . how can I do it in unix command .

Example of Log file :

 Start Loading                     ---Thu Aug  2 17:14:09 EDT 2012
 Load completed   successfully---Fri Aug  3 09:00:44 EDT 2012

This may be simple on some systems and extremely difficult in others. What's your OS and shell? uname -a if you don't know.

If you have Linux, converting dates into timestamps is straightforward:

$ date +%s -d "Thu Aug  2 17:14:09 EDT 2012"

1343942049

$

...and getting the difference between two times becomes a matter of simple arithmetic.

OS is AIX .

We changed the code and put the following logic

START=$SECONDS
END=$SECONDS
echo elapsed time is $((END-START)) seconds

Can any one help how to convert this seconds in HH MM SS format

That comes down to math.

SS=$(( (END-START) % 60 ))
MM=$(( ((END-START) / 60) % 60 ))
HH=$(( ((END-START)/(60*60))%24 ))

Not sure but does AIX have the 'time' command? If so, preface your command with the time command

time <your command>

This will provide the system time, the user time and the total time.