Yesterday when the computer room was waiting to replicate the data (332G), really waiting for the boredom, wrote such a thing; mainly used when starting a copy operation, if the volume is large, we have to wait for it to complete, every time through du view of the data, we have to calculate to know how long; this is very troublesome, so I thought, This should be a very simple script;
First said operating premise, first have to copy the east, file or directory, and then give the script a time interval, the script through the interval to calculate the average rate of replication per second, and then to tell the script source files and target files, of course, the directory can also.
As follows:
./script.sh 10/nfs/opensuse-11.2-dvd-x86_64.iso/opt/os/opensuse-11.2-dvd-x86_64.iso
speed:13.20mb/s; DONE:0.12GB; 121.00MB # Average Speed per second, the number of GB completed, MB How many
time:5.45 sec; HAVE:4.22GB; 4316.41MB # How many minutes are expected to be needed, how many are not replicated, the size of the GB,MB
The code is as follows:
#!/bin/bash
dir1=${2:-/var/log/}
dir2=${3:-/var/log/}
Inv=${1:-30}
Help () {
echo Usage: $ interval/path/source/dir//path/destination/dir/"
Echo" Exam: $30/opt/data/bak//mnt/disk1/"
Exit 1
}
[-Z $] && help
ct= ' du-s $DIR 1|awk ' {print $} '
bfr= ' du-s $DIR 2|awk ' {print} '
Sleep $INV
aft= ' du-s $DIR 2|awk ' {print} '
dmb= ' echo $AFT |awk ' {printf ("%.2lf", $1/1024)} '
Dgb= ' echo $ Aft|awk ' {printf (%.2LF, $1/1024/1024)} '
mb= ' echo $AFT $BFR $INV |awk ' {printf ('%.2lf ', ($1-$2)/$3/1024)} '
echo "Speed: $MB" MB/s; Done: "$DGB" GB; "$DMB MB"
Etime= ' echo $CT $AFT $MB |awk ' {printf ("%.2lf", ($1/1024-$2/1024)/$3/60)} '
egb= ' echo $CT $AFT |awk ' { printf ("%.2lf", ($1-$2)/1024/1024)} '
emb= ' echo $CT $AFT |awk ' {printf ('%.2lf ', ($1-$2)/1024)} '
Echo ' time: $ ETime sec; Have: "$EGB" GB; "$EMB MB"
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/