AMP AMP

How to track the ongoing file operations using pv command

To track the ongoing file operations using pv command

In this article we will discuss about monitoring the process while copying or moving data in Linux system. The pv command helps to view the progress while transferring the data. It displays the information like elapsed time, throughput rate, data transferred and ETA.

To Install pv Command

On Fedora, CentOS and RHEL

[root@linuxhelp ~]# yum install pv
Resolving Dependencies
-->  Running transaction check
--->  Package pv.x86_64 0:1.6.0-1.el6 will be installed
-->  Finished Dependency Resolution
Dependencies Resolved
=====================================================================================
 Package                          Arch                                 Version                                    Repository                            Size
=====================================================================================
Installing:
 pv                               x86_64                               1.6.0-1.el6                                ivarch                                63 k
Transaction Summary
=====================================================================================
Install       1 Package(s)
Total download size: 63 k
Installed size: 116 k
Is this ok [y/N]: y
Downloading Packages:
pv-1.6.0-1.x86_64.rpm                                                                                                                 |  63 kB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : pv-1.6.0-1.el6.x86_64                                                                                                                     1/1 
  Verifying  : pv-1.6.0-1.el6.x86_64                                                                                                                     1/1 

Installed:
  pv.x86_64 0:1.6.0-1.el6                                                                                                                                    
Complete!

On Debian, Ubuntu and Linux Mint

# apt-get install pv

On FreeBSD Linux

# cd /usr/ports/sysutils/pv/
# make install clean


If you want to add binary package.

# pkg_add -r pv


On Gentoo Linux

# emerge --ask sys-apps/pv

Syntax of pv command

$ pv [Filename]

Options used with pv commands

-p is used to on the display bar
-timer is used to view the elapsed time
-eta is used to turn on eta timer
-bytes is used to view total amount of data transferred
-n is used to display progress informations
-rate is used to on rate counter

Output modifiers
&ndash size SIZE is used to assume the total amount of data transferred
&ndash interval SECONDS is used to specify seconds between updates
&ndash force is used to force an operation
&ndash help is used to display all the possible options used

To copy files

[user1@linuxhelp Desktop ]$ pv Ubuntu-15.10-server-amd64.iso >  imagefiles/ubuntu-15.10-server_64.iso
632MiB 0:00:29 [21.2MiB/s] [================================> ] 100%            

To make a zip file

[user1@linuxhelp Desktop]$ pv ubuntu-15.10-server-amd64.iso | zip >  zip/ubuntu-15.10-server_64.zip
  adding: -28.1MiB 0:00:01 [28.1MiB/s] [>                                  ]  4%  632MiB 0:00:29 [21.3MiB/s] [================================> ] 100%            
 (deflated 2%)

To count the number of lines, bytes and words

[user1@linuxhelp ~]$ pv -p /etc/passwd | wc
[========================================================================> ] 100%
     43      69    2122

Monitoring the process of tar utility using pv tool

[user1@linuxhelp Desktop]$ tar -czf - zip/ | (pv -p --timer --rate --bytes >  tarfile.tgz)
 616MiB 0:00:32 [18.8MiB/s] [                                                          < =>                               ]

To create a dialog progress bar using pv

Before running the command make sure that you have installed dialog package.If not installed use the below command to install the package.

[root@linuxhelp Desktop]# yum install dialog

Now run the pv command to get the dialogue progress

[user1@linuxhelp Desktop]$tar -czf - zip/ | (pv -n >  gzip.tgz) 2> & 1 | dialog --gauge " Progress"  10 70

FAQ
Q
What speeds do I need for streaming or large downloads?
A
If you’re asking this question, you’re already sick of the wheel of constant buffering.
Q
What is the essential purpose of pv?
A
The pv command helps to view the progress while transferring the data
Q
How to format hard disk with dd command using pv?
A
You can make use of the following command dd if=/dev/zero | pv -pbtr -s 120033041920 | dd of=/dev/sdX
Q
How to create a dialog progress bar?
A
You can make Use of "yum install dialog"
Q
How to find the progresses information?
A
"-n" is used to display progress informations