PV command monitors execution progress of Linux commands

Source: Internet
Author: User

PV command monitors execution progress of Linux commands

Http://www.techweb.com.cn/network/system/2015-12-14/2241124.shtml

Yum Install -y PVcp mysql-5.6. -LINUX-GLIBC2. 5-x86_64. tar. GZ mysql-5.6. -LINUX-GLIBC2. 5-X86_64AA|PV-TB >/dev/null0:xx:

CentOS installed by Yum version of the PV command is 1.1, does not support the-a parameter, simply rely on the-BT parameter looks still a little tired, Ubuntu through apt warehouse PV version is 1.2

rpm-qa| grep PVPV-1.1. 4-3. el6.x86_64

-p to display percentages,-N uses numbers to display percentages,-t to show time,-R for transfer rate,-E for ETA (estimated time remaining)

PV, which displays progress information for the command currently executing at the command line. In this article we will discuss it and illustrate its characteristics in a few simple examples. The
PV command
PV was developed by Andrew Wood and is the short name of the pipe Viewer, means information about the progress of data processing through a pipeline. This information includes the time that has been spent, the percentage of completion (shown through the progress bar), the current speed, the total data transferred, and the estimated time remaining.
To use PV, you need to fit the appropriate option to place it in a pipeline between two processes. The standard input of the command will pass through the standard output, and the progress will be output to the standard error output. "
The above explanation comes from the help page of the command.
Download and install
The Debian system, such as Ubuntu, can be installed using the following command:
sudo apt-get install PV
If you are using a different distribution, You can use the respective package management software to install PV on your system. Once PV is installed, you can use it on various occasions (see below). It is important to note that all of the following examples use the PV 1.2.0   
Features and usage
Most of the usage scenarios of our (users using the command line on Linux) are the commands to copy movie files from a USB drive to your computer. If you use CP to accomplish the above tasks, you will not know what is going on until the entire replication process is complete or error-prone.
However, the PV command is helpful in this scenario. For example:
pv/media/himanshu/1ac2-a8e3/fnf.mkv >./desktop/fnf.mkv
Output is as follows:

Pv-copy
So, as you can see, this command shows a lot of useful information about the operation, including the amount of data that has been transferred, the time spent, the transfer rate, the progress bar, the percentage of progress, and the remaining time.
The PV command provides a variety of display options switches. For example, you can use-p to display percentages,-t to show time,-R for transfer rate, and-E for ETA (estimated time remaining). The good thing is that you don't have to remember an option because the default options are enabled. However, if you only have one of these messages, you can complete the task by controlling these options.
There is also a-n option to allow the PV command to display an integer percentage, and a number for each line on the standard error output to replace the usual visual progress bar. Here is an example:
Pv-n/media/himanshu/1ac2-a8e3/fnf.mkv >./desktop/fnf.mkv

Pv-numeric
This particular option is well suited for situations where you want to pass the output to the dialog command with a pipeline.
Next, there is a command-line option,-l allows you to modify the transmission rate of the PV command. As an example, use the-l option to limit the transfer rate to 2mb/s.
Pv-l 2m/media/himanshu/1ac2-a8e3/fnf.mkv >./desktop/fnf.mkv

Pv-ratelimit
As you can see, the data transfer speed is limited as per our requirements.
Another scenario where PV can help is to compress files. Here's an example to explain how to work with compression software gzip.
pv/media/himanshu/1ac2-a8e3/fnf.mkv | gzip >./desktop/fnf.log.gz

Pv-gzip
Conclusion
As mentioned above, PV is a very useful gadget that can save you valuable time if the command does not perform as expected. And the displayed information can also be used in shell scripts. I strongly recommend you to use this command, it is worth a try.

PV command monitors execution progress of Linux commands

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.