Understanding and Using pv (Pipe Viewer) for Data Transfer Monitoring and Rate Limiting
This article explains what the pv (Pipe Viewer) tool is, its functions such as monitoring data flow and rate limiting, how to install it on various Linux distributions, and provides practical command‑line examples for measuring transfer speed and throttling bandwidth.
pv (Pipe Viewer) is not a page‑view counter but a command‑line utility that lets users observe what happens inside a Unix pipeline, showing progress, transfer speed, elapsed time, and more.
The official manual (accessed via man pv or pv(1) ) describes pv as a tool for visualizing pipeline activity, allowing users to see data flow rates and estimated completion times.
Key capabilities include: • Displaying the data flow rate in a pipeline. • Showing the elapsed time of data transfer. • Estimating completion time based on expected data size. • Limiting the transfer rate with the -L RATE option.
Rate limiting is useful when copying data across networks or writing to disks, preventing a single operation from saturating bandwidth or I/O resources; pv’s -L flag lets you throttle any command that reads from standard input.
Installation is straightforward on Red Hat‑based systems ( sudo yum install pv ) and can be built from source on other distributions using the typical ./configure && make && make install sequence.
Practical examples: time psql -U qa -h somehost.qunar.com -d vacation -f t3.sql | pv -t -r > /dev/null – monitors a slow PostgreSQL query, showing transfer rate and elapsed time. tar cf - result.data | pv -e -t -b -L 100k | ssh user@host 'tar xvf -' – copies a large data set to a remote host while limiting the bandwidth to 100 KB/s.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.