Home » Infrastructure » Unix » Time taken to compress a file
Time taken to compress a file [message #154788] Tue, 10 January 2006 10:48 Go to next message
toshidas2000
Messages: 120
Registered: November 2005
Senior Member
All
How do I know, how much time it took to compress a file.

If I do
$ date
$ compress file_name

I have to keep an eye on monitor to see when it finishes and do date again.

Like oracle has set timing on and gives exact time taken to complete a command, do we have any similar on Unix (solaris).

Please help

Thanks
Re: Time taken to compress a file [message #154822 is a reply to message #154788] Tue, 10 January 2006 15:43 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
as far as I know, there is no way to do direct date arithmetic in shell scripting. You can do it in Perl and then call the Perl from your shell script.
Re: Time taken to compress a file [message #154844 is a reply to message #154822] Tue, 10 January 2006 23:25 Go to previous messageGo to next message
tarundua
Messages: 1080
Registered: June 2005
Location: India
Senior Member

You can do something like this,

create a shell script
 $cat > elapsed_time.sh
 start_time=`date '+%d/%m/%y %H:%M:%S'`
 compress file_name # your command
 end_time=`date '+%d/%m/%y %H:%M:%S'`
 echo $start_time
 echo $end_time
 


so when you run the script you will get the start time as well as the end time.
Re: Time taken to compress a file [message #154865 is a reply to message #154788] Wed, 11 January 2006 01:23 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Just prefix the command with 'time'

time compress filename


Or, you really want to do the subtraction yourself, issue 3 commands in one line:

date; compress filename; date

_____________
Ross Leishman
Re: Time taken to compress a file [message #154875 is a reply to message #154865] Wed, 11 January 2006 01:53 Go to previous messageGo to next message
tarundua
Messages: 1080
Registered: June 2005
Location: India
Senior Member

Wow, This command is new for me i.e. time.

Thanks R.Leishman.
Re: Time taken to compress a file [message #154938 is a reply to message #154865] Wed, 11 January 2006 07:45 Go to previous messageGo to next message
toshidas2000
Messages: 120
Registered: November 2005
Senior Member
thanks a lot. The output shows three time what are those??

real 22m40.72s
user 15m42.62s
sys 1m44.95s

Thanks
Re: Time taken to compress a file [message #155954 is a reply to message #154788] Thu, 19 January 2006 19:22 Go to previous messageGo to next message
*Jess*
Messages: 48
Registered: December 2005
Location: Penang, Malaysia
Member

Does this mean that the system can automatically estimate the duration for the compression to be end? The time should appeared before the compress job ended. This is from my understanding, correct me if I'm wrong.

Thanks.
Re: Time taken to compress a file [message #155969 is a reply to message #155954] Fri, 20 January 2006 00:48 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
The output of time command appears immediately before control is passed back to the shell. So NO, it doesn't estimate.

: c985675 ~/sql; time sleep 6

real    0m6.096s
user    0m0.000s
sys     0m0.080s


The one you want is the 'real' time. It measures elapsed time.

I believe 'sys' is like 'cpu' time. Not sure what 'user' is.

_____________
Ross Leishman
Previous Topic: Negative value returned from a SQL to a shell script
Next Topic: Unable to connect as SYSDBA
Goto Forum:
  


Current Time: Mon Nov 25 18:15:07 CST 2024