LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Howto Monitor elapsed time in a shell script (http://www.linuxquestions.org/questions/linux-software-2/howto-monitor-elapsed-time-in-a-shell-script-156222/)

rkrijger 03-11-2004 05:13 AM

Howto Monitor elapsed time in a shell script
 
I have a script that creates a backup for me. I would like to keep track of its progress, so I would like to see, every second (or so), the time elapsed and the size of the backup file. I manage to get the size of the backup file, but I cannot get the elapsed time to work.

This is what i have:

1. To create the backup:

#!/bin/sh
tarfile=$TMPDIR/fullhd.tgz
every 1 sys_echosize $tarfile &
every_pid=$!
tar cfz $tarfile .
kill $every_pid

2. The "every" script performs a cmd every few seconds:

#!/bin/sh
t=$1
shift
while true ; do
$*
sleep $t
done

3. The "sys_echosize" is as follows:

#!/bin/sh
echo -e -n " " `du -h $1` "\r"




Nice, isn't it?!? :)
But not finished, as I would like to have the time elapsed of the tar command...

Any help would be appreciated!!!

Regards,
Robin...

dopefish 03-11-2004 08:07 AM

check out the time command displays times used to execute another command/script

rkrijger 03-11-2004 08:46 AM

Quote:

Originally posted by dopefish
check out the time command displays times used to execute another command/script
Thanks! I did, but could not get it working in the above scripts...
Currently, the output is something like:

640M /tmp/fullhd.tgz

And I would like it to be something like (after 4.5 minutes backupping):

640M /tmp/fullhd.tgz (4m:30s)

and (after 5 minutes of backupping):

695M /tmp/fullhd.tgz (5m:00s)

A clou?!?


All times are GMT -5. The time now is 08:17 PM.