LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 03-11-2004, 05:13 AM   #1
rkrijger
LQ Newbie
 
Registered: Mar 2003
Posts: 17

Rep: Reputation: 0
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...
 
Old 03-11-2004, 08:07 AM   #2
dopefish
Member
 
Registered: Nov 2003
Location: Northcliffe, WA
Distribution: Slackware 12.0
Posts: 481

Rep: Reputation: 30
check out the time command displays times used to execute another command/script
 
Old 03-11-2004, 08:46 AM   #3
rkrijger
LQ Newbie
 
Registered: Mar 2003
Posts: 17

Original Poster
Rep: Reputation: 0
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?!?

Last edited by rkrijger; 03-11-2004 at 09:08 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
find elapsed time innuendo_98 Programming 2 11-10-2005 08:03 AM
amarok progressbar time elapsed problem abattoir Linux - Software 0 04-13-2005 10:31 AM
elapsed time formula for open office calc philosophe Linux - Software 1 03-30-2005 05:32 AM
Help with Howto start a shell script at boot draven Linux - Newbie 7 03-03-2004 11:20 PM
getting elapsed time.. Mad_C Programming 2 04-01-2003 01:12 AM


All times are GMT -5. The time now is 11:09 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration