Information statistics scripts for large file or directory replication

Source: Internet
Author: User
Tags printf time interval

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.