Solved

"date2 - date1": elapsed time in hrs, mins, and secs

Posted on 2004-08-06
6
909 Views
Last Modified: 2010-04-21
How to calculate the elapsed time in hrs, mins, and secs:

For example, in the script, it has

d1=`date`
......
d2=`date`

How to get the time difference between d2 and d1.

Thanks.
0
Comment
Question by:geermu
6 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 63 total points
ID: 11733410
0
 
LVL 48

Expert Comment

by:Tintin
ID: 11748780
As an alternative.

man time
0
 
LVL 7

Assisted Solution

by:glassd
glassd earned 62 total points
ID: 11771799
Perl's Date::Calc module is ideal for this task.
0
 
LVL 5

Expert Comment

by:ITcrow
ID: 11865515

You have multiple options here:

perl:  
$start_time = time();
<Your Script Here>
$end_time  = time();
$time_taken =  $start_time - $end_time;

Or use some CPAN module: benchmark, Date::Calc, etc.

*nix Shell Cmd Line:
prompt> time <Your Script Here>

I am not aware which shell you are working in. Otherwise I could have suggested
a shell specific calculation.

Use of perl will make it Shell and OS independent, which is a good thing in long run.

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded‚Ķ
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question