check cp progress in linux

How to Check Cp Progress in Linux

When you copy/move large amount of files/data via Linux terminal, it will remain blank as long as the task does not complete. In such cases, you may want to monitor the progress of task. Otherwise, you may not know if the system hangs up in between. There are many Linux utilities for this purpose. In this article, we will learn how to check cp progress in Linux using pv command.


How to Check Cp Progress in Linux

Pv is a command-line tool that allows you to monitor the progress of data sent via pipe. It provides the following information during data transfer:

  • The time that has elapsed
  • The percentage completed including a progress bar
  • Shows current throughput rate
  • The total data transferred
  • and the ETA (estimated Time)

Here are the different commands to install pv command on your system.

Fedora, CentOS, RHEL

# yum install pv
# dnf install pv            [On Fedora 22+ versions]

Debian/Ubuntu Linux

# apt-get install pv

Once you have installed pv command, you can use it in a pipeline between two processes. The standard input of pv command will be passed through to its standard output and progress will be displayed on standard error, like cat command.

Here are some example command syntaxes.

pv file
pv options file
pv file > filename.out
pv options | command > filename.out
comand1 | pv | command2 

pv command is typically used to display progress by applications and scripts that lack the ability to do so on their own.

pv command’s output consists of 3 parts – display switches, output switches, and general options.

Here are some common options under display switches

  1. -p – turn on the display bar
  2. -timer to view the elapsed time
  3. -eta to turn on ETA timer to guess how long it will take before completion of an operation
  4. -rate to turn on a rate counter
  5. -bytes to display the total amount of data transferred so far
  6. -n to display progress inform of integer percentage instead of visual indication

Here are some options under output modifiers

  1. –wait to wait until the first byte is transferred before displaying progress information
  2. –size SIZE to assume the total amount of data to be transferred
  3. –interval SECONDS to specify seconds between updates
  4. –force option to force an operation
  5. –help to display usage information and –version to display version information

Here are some commonly used examples of pv command.

By default, pv command runs with -p, -t, -e, -r, -b options.

1. Here is the command to view cp progress while copying file data.iso to /home/ubuntu.

# pv data.iso > /home/ubuntu/data.iso

2. Here is an example to view the progress of making zip file using pv.

# pv /var/log/syslog | zip > syslog.zip

3. Here is the pv command while creating tarball from a folder.

# tar -czf - ./Downloads/ | (pv -p --timer --rate --bytes > backup.tgz)

4. Here is the pv command to display progress while counting number of words in a file using wc command.

# pv -p /etc/hosts | wc

In this article, we have learnt how to view progress of task/process using Linux. pv is a very useful tool tha can be used with commands and tasks that do not possess the ability to display progress. You can easily use it to display progress when you copy/move/compress/backup data on your system.

Also read:

How to Run Fsck to Fix File System Error in Linux
How to Increase Open File Limit in Linux
How to Count Total Lines of Code in Directory Recursively
How to Fix Yum Error: Database Disk Image Malformed
How to Fix “Failed to Mount /etc/fstab”

Leave a Reply

Your email address will not be published. Required fields are marked *