pv 测量数据传输进度工具

发布时间: 更新时间: 总字数:660 阅读时间:2m 作者: IP上海 分享 网址




  • 网络流量统计
  • 数据备份、复制或转换过程中,数据传输的进度以及预计的剩余时间


apt install pv


pv --help ...
$ pv --help
Usage: pv [OPTION] [FILE]...
Concatenate FILE(s), or standard input, to standard output, with monitoring.

  -p, --progress                 show progress bar
  -t, --timer                    show elapsed time
  -e, --eta                      show estimated time of arrival (completion)
  -I, --fineta                   show absolute estimated time of arrival (completion)
  -r, --rate                     show data transfer rate counter
  -a, --average-rate             show data transfer average rate counter
  -m, --average-rate-window SEC  compute average rate over past SEC seconds (default 30s)
  -b, --bytes                    show number of bytes transferred
  -8, --bits                     show number of bits transferred
  -T, --buffer-percent           show percentage of transfer buffer in use
  -A, --last-written NUM         show NUM bytes last written
  -F, --format FORMAT            set output format to FORMAT
  -n, --numeric                  output percentages, not visual information
  -q, --quiet                    do not output any transfer information at all

  -W, --wait                     display nothing until first byte transferred
  -D, --delay-start SEC          display nothing until SEC seconds have passed
  -s, --size SIZE                set estimated data size to SIZE bytes
  -l, --line-mode                count lines instead of bytes
  -0, --null                     lines are null-terminated
  -i, --interval SEC             update every SEC seconds
  -w, --width WIDTH              assume terminal is WIDTH characters wide
  -H, --height HEIGHT            assume terminal is HEIGHT rows high
  -N, --name NAME                prefix visual information with NAME
  -f, --force                    output even if standard error is not a terminal
  -c, --cursor                   use cursor positioning escape sequences

  -L, --rate-limit RATE          limit transfer to RATE bytes per second
  -B, --buffer-size BYTES        use a buffer size of BYTES
  -C, --no-splice                never use splice(), always use read/write
  -E, --skip-errors              skip read errors in input
  -Z, --error-skip-block BYTES   skip errors in BYTES blocks at a time
  -S, --stop-at-size             stop after --size bytes have been transferred
  -Y, --sync                     flush cache to disk after every write
  -K, --direct-io                use direct I/O to bypass cache
  -X, --discard                  discard input instead of writing to output
  -R, --remote PID               update settings of process PID

  -P, --pidfile FILE             save process ID in FILE

  -d, --watchfd PID[:FD]         watch file FD opened by process PID

  -h, --help                     show this help and exit
  -V, --version                  show version information and exit

Please report any bugs to: pv@ivarch.com



tcpdump -i ens33 -w - | pv -bert > /dev/null
# 12.0KiB 0:00:02 [8.00  B/s]


# 生成 76M 数据
seq 1 500000000 > text.txt
du -lh text.txt

# 监视一个文件从源目录复制到目标目录的进度
$ pv text.txt > /tmp/text.txt
1.12GiB 0:00:03 [ 232MiB/s] [================>                                 ]  24% ETA 0:00:06

# 指定格式
$ pv -F 'Transfer: %t Elapsed: %e Transfer rate: %r' text.txt > /tmp/text.txt
Transfer: 0:00:01 Elapsed: ETA 0:00:04 Transfer rate: [ 816MiB/s]


tar cf - source_directory/ | pv -s $(du -sb source_directory/ | awk '{print $1}') | gzip > archive.tar.gz


限制为 1MB/s

$ cat text.txt | pv -L 1M > /tmp/text.txt
2.00MiB 0:00:02 [1023KiB/s] [   <=>                           ]
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数