The pv command allows you to see the progress of data through a pipeline. It provides the following info:
Time elapsedPercentage completed (with progress bar)Current throughput rateTotal data transferredETA
From the project home page:
It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.
By default pv command is not installed. Type the following apt-get command under Debian / Ubuntu Linux:
# apt-get install pv
Sample outputs:
RHEL / CentOS / SL / Fedora Linux users, turn on EPEL repo and type the following yum command to install pv:
# yum install pv
Sample outputs:
FreeBSD users can use the port to install pv, enter:
# cd /usr/ports/sysutils/pv/
# make install clean
OR add the binary package, run:
# pkg_add -r pv
The syntax is
pv filenamepv filename > /path/to/outputpv options filename | command1pv options filename | command1 > output.filepv filename | command1command1 | pv | command2pv -options input.file | command1 | pv -options > output.fileIn this example copy a file called origin-cdn.cyberciti.org_access.log to /tmp/origin-cdn-access.log and show progress:
# pv origin-cdn.cyberciti.org_access.log > /tmp/origin-cdn-access.log
OR just send it to /dev/null:
# pv origin-cdn.cyberciti.org_access.log > /dev/null
Use nc to create a network port # 2000. Type the following command:
$ nc -l -v -w 30 -p 2000 > /tmp/data.bin
Open another terminal and type:
$ pv firmware33921.bin | nc -w 1 127.0.0.1 2000
Sample outputs:
In this example you can see progress of both pipes: pv -cN rawlogfile origin-cdn.cyberciti.org_access.log | gzip | pv -cN gziplogfile > access.log.gz
Sample outputs:
Fig.02: pv displaying output of complicated pipes and commandsWhere, -c : Use cursor positioning escape sequences instead of just using carriage returns. This is useful in conjunction with -N (name) if you are using multiple pv invocations in a single, long, pipeline.N rawlogfile : Prefix the output information with NAME. Useful in conjunction with -c if you have a complicated pipeline and you want to be able to tell different parts of it apart. echo percentage | dialog --gauge "text" height width percentecho "10" | dialog --gauge "Please wait" 10 70 0echo "50" | dialog --gauge "Please wait" 10 70 0echo "100" | dialog --gauge "Please wait" 10 70 0
In this example, extract tar ball and show progress using the dialog command:
(pv -n backup.tar.gz | tar xzf - -C path/to/data ) 2>&1 | dialog --gauge "Running tar, please wait..." 10 70 0Sample outputs:
Fig.03: pv and dialog command in actionFinally, you can always use the rsync command to display progress bar for both local and remote files.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Nenhum comentário:
Postar um comentário