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:
every 1 sys_echosize $tarfile &
tar cfz $tarfile .
2. The "every" script performs a cmd every few seconds:
while true ; do
3. The "sys_echosize" is as follows:
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!!!
check out the time command displays times used to execute another command/script
Currently, the output is something like:
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)
|All times are GMT -5. The time now is 12:28 AM.|