Live data from Hacker News

Progress – A Tool to Monitor Progress for Commands in Linux (2016)

tecmint.com

21–30 of 42 posts

Re: Progress – A Tool to Monitor Progress for Commands in Linux (2016)

#21
post #8
post #3

With respect to cp and mv, I've found that rsync is often a good alternative for anything more than trivial moves and copies.

rsync's ability to resume is especially handy.

It can also avoid IO using hashed blocks.

Re: Progress – A Tool to Monitor Progress for Commands in Linux (2016)

#22
post #6

I know what I am about to say is an absolutely ugly hack, but... If you cannot install non-standard software (example: customer owner, company operated RHEL boxes) you can get an idea of the current progress of cp/tar and similar programs by inspecting file-descriptor files in /proc. Assuming that you have a process (like cp) with pid 1234, then in /proc/1234/fd you will find files with a number (corresponding to the…

#!/bin/sh for pid in $@; do cd /proc/"$pid"/fd || continue for fd in *; do file=$(readlink "$fd"); if [ ! -z "$file" ]; then size=$( (du -b "$file" 2>/dev/null || echo 0) | awk '{print $1}') if [ "$size" = "0" ]; then continue fi pos=$(

I ended up writing very similar code to do the same thing: https://gist.github.com/jhlb/83999422a8d7e8a6e28e

EDIT: as mentioned elsewhere in the thread, the pv program has a way to watch a PID as well that makes this program unnecessary.

Re: Progress – A Tool to Monitor Progress for Commands in Linux (2016)

#23
post #4

On macOS you can monitor the progress of many commands with Ctrl-T. With cp for example: $ cp Test Test2 ^T load: 3.42 cmd: cp 86526 running 0.01u 4.36s Test -> Test2 6%

On FreeBSD, in addition to the ^T, procstat -af is often useful.

Re: Progress – A Tool to Monitor Progress for Commands in Linux (2016)

#24
This is my super-simple progress indicator, called dots. I wrote it at least 12 years ago when I was on a slow terminal and wanted to know unpacking a tarball was still progressing (the verbose output would have taken too much bandwidth!). Now I copy it onto every new system I use.

It prints one period (.) for every 1000 lines of text piped into it. It just shows that there is still activity, not progress, but often this is enough.

A typical usage is:

  tar xvfz some_huge_tarball.tar.gz | dots
It defaults to one dot per 1000 lines, but the first argument can be a number to specify another interval.

  #!/usr/bin/perl

  $| = 1;
  $i = 0;

  if ($#ARGV ) {
    print '.' unless ($i % $number);
    $i++;
  }

  print "\n";

Re: Progress – A Tool to Monitor Progress for Commands in Linux (2016)

#26

Usually I have used pv. https://linux.die.net/man/1/pv cp pv source > target tar tar czf images.tar.gz image1 image2 image3 | pv > target gzip pv source | gzip > target.gz # or gzip

Comes with rate limiting too. "-L 25k" keeps the network guys off my back when I have to copy logs across continents.

Re: Progress – A Tool to Monitor Progress for Commands in Linux (2016)

#27
post #4

On macOS you can monitor the progress of many commands with Ctrl-T. With cp for example: $ cp Test Test2 ^T load: 3.42 cmd: cp 86526 running 0.01u 4.36s Test -> Test2 6%

SIGINFO is very useful. I make it a point to implement support for it whenever it makes sense. Wish Linux would get it.
Post reply on HN