It is well known that Linux administrators need to monitor commands in real time so that they know that commands are being executed smoothly and not suspended. But many users do not know how to operate this command, here is a look at the U warrior using PV command to monitor the completion of Linux command method introduction.
Often Linux commands do not provide information about progress, which is especially important if you have limited time. That doesn't mean you're helpless though - there's now a command, pv, that displays the progress of the commands currently being executed on the command line. In this article we will discuss it and illustrate its features with a few simple examples.
The PV command, developed by Andrew Wood, is short for Pipe Viewer, which means to display data processing progress information through the channel. This information includes the amount of time already spent, the percentage of completion (shown by the progress bar), the current speed, the total data transferred, and the estimated time remaining. "To use PV, you need to place it in the channel between two processes with the appropriate option. The standard input of the command will come in through standard output, and the progress will be output to standard error output." The above explanation comes from the command's help page.
To download and install a Debian operating system, such as Ubuntu, you can simply install pv using the following command: sudo apt-get install pv If you are using another distribution, you can use the respective package software to install PV on your system. Once the PV is installed you can use it in a variety of situations (see below). Note that all of the following examples use pv 1.2.0.
Features and usage Most of our usage scenarios (for those who use the command line on linux) will use the command to copy movie files from a USB drive to your computer. If you use cp to accomplish the above tasks, you won't know until the entire replication process is over or something goes wrong. However, the pv command is helpful in this situation. : pv /media/himanshu/1AC2-A8E3/fNf.mkv >./Desktop/fnf.mkv
The output is as follows: pv-copy So, as you can see, this command displays a lot of useful information about the operation, including the amount of data that has been transferred, the time taken, the transfer rate, the progress bar, the percentage of progress, and the time remaining. The pv command provides a variety of display option switches. You can use -p to show the percentage, -t to show the time, -r for the transfer rate, and -e for eta. The good news is that you don't have to remember any of the options because they are enabled by default. However, if you only want one of these information, then you can control the several options to accomplish the task. There is also a -n option to allow the pv command to display integer percentages, one number per line on the standard error output, in place of the usual visual progress bar. Here is an example: pv-n /media/himanshu/1AC2-A8E3/fNf.mkv >./Desktop/fnf.mkv
The specific pv-numeric option is suitable for situations where you want to pass the output to the dialog command. Next there is a command line option, -L, which allows you to modify the transfer rate of the pv command. For example, use the -L option to limit the transfer rate to 2MB/s. pv-L 2m /media/himanshu/1AC2-A8E3/fNf.mkv >./Desktop/fnf.mkvpv-ratelimit As shown in the figure above, the data transmission speed is limited according to our requirements. Another scenario where pv can help is with compressed files. Here is an example that will explain to you how to work with the compression software Gzip. pv /media/himanshu/1AC2-A8E3/fnf.mkv | gzip >./Desktop/fnf.log.gzpv-gzip Conclusion As mentioned above, pv is a very useful gadget. It can save you valuable time when commands don't execute as expected. The information displayed can also be used in shell scripts. I highly recommend you to use this command, it's worth a try.