Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by danieldk on Saturday July 12, 2014 @07:28AM
(#8024285)
Slightly related: what many people don't know is that on OS X and BSDs, commands often react to SIGINFO (Ctrl-t), giving progress information. E.g. from the cp man page:
If cp receives a SIGINFO (see the status argument for stty(1)) signal,
the current input and output file and the percentage complete will be
written to the standard output.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by na85 on Saturday July 12, 2014 @07:47PM
(#8026138)
As far as I'm aware, Linux tools do react to various signals, just not SIGINFO because it comes from BSD and Linux just doesn't use that particular signal.
You can check dd progress by sending USR1, for example.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by koenigdavidmj on Saturday July 12, 2014 @03:53PM
(#8025622)
pkill -USR1 dd
You'll need to use ps to get the pid if you've got multiple dd instances running, and you'll of course need to run that as root if your dd instance is running as root.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by jamescun on Saturday July 12, 2014 @06:23AM
(#8024180)
For a verbose or simple progress `cp` equivalent I tend to use RSync. Both RedHat/CentOS/etc and Debian/Ubuntu all come with RSync as standard. The only caveat is that I find RSync to be slightly slower than coreutils cp; however you do gain all the advantages of RSync if you then need to sync files across the network for example.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by to3m on Saturday July 12, 2014 @06:29PM
(#8025972)
I've found Midnight Commander (https://www.midnight-commander.org/) good if you just need the progress bar. In fact, you get not just one, but TWO - one for the individual file, and one for the transfer as a whole. Perhaps I'm easily pleased, but I find this useful.
(It doesn't do all the rsync fanciness, but if you don't need that and/or you've got some unwieldy subset of files to transfer - a situation the GUI-style approach makes light work of - then it comes in handy.)
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by hrjet on Saturday July 12, 2014 @05:22AM
(#8024103)
About 10 years back I tried to do this by defining terminal escape codes for this. I was also implementing a new terminal as a POC. Unfortunately didn't find the time to go beyond it.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by fyrabanks on Saturday July 12, 2014 @05:41AM
(#8024124)
pv is by no means a standard include. Also the obvious advantage here is being able to monitor progress for processes you didn't pipe to pv initially (e.g., forgot or didn't think it would be a long transfer).
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by teraflop on Saturday July 12, 2014 @10:04PM
(#8026399)
You can start pv without an estimated size, run du in the background, and then supply the estimate to pv once it's calculated using the '-R' (remote control) option.
A bit clumsy, but it shouldn't be hard to write a little script to do it.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by ithkuil on Saturday July 12, 2014 @10:15PM
(#8026417)
Cool, didn't know about that pv had a remote control.
Anyway, if cp -R had a progress bar it would behave the same way, i.e. it would have first to recursively stat the source the same way as du does, and only then it could start reporting a completion percentage.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by justincormack on Saturday July 12, 2014 @05:07AM
(#8024090)
dd has progress built in, under Linux it is kill -USR1 <pid> to get a progress report, the signal varies by OS. cp has a -v option, if tahts not enough rsync has a --progress option too that gives within file progress.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by skore on Saturday July 12, 2014 @02:25PM
(#8025350)
If anybody is using dd to rescue a failing drive, I can very much recommend using the spectactular ddrescue instead.
I had a 2TB drive turn up five figure error rates (Raw Read Error rate ended up at 90k - when I started, it was already no longer possible to mount it, but it did show up in /dev) and thought I had lost an entire year of family pictures (mea culpa on not having a backup, of course). It took four months, 24/7 of meticulous work, but it ended up giving me a near perfect copy to an identical drive (save for ~20kb of truly dead sectors).
Amongst many other features, it has a logfile where it keeps track of the overall process - so that it can be killed or paused and restarted later.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by lobster_johnson on Saturday July 12, 2014 @11:59AM
(#8024867)
Entirely feasible, as far as I know; OS X lets you discover processes and access their devices. OS X, being BSD-based, doesn't have a /proc file system; instead, you have to use sysctl() to get at the data.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by kator on Sunday July 13, 2014 @08:55AM
(#8027243)
In the old days I've done this using lsof -p PID and looking at where the files are in relationship to their size. If you have a long running process lsof can be a wonderful tool to figure out how it's doing.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc.
by jackmaney on Saturday July 12, 2014 @08:41PM
(#8026230)
A completely unrelated question: in the terminal screenshots, what is being used for PS1? I love that display of the CWD and git repo on the command line.
You can check dd progress by sending USR1, for example.
> rsync --progress <source> <destination>
> rsync --progress /home/me/music/*.mp3 /mnt/shared/music
(It doesn't do all the rsync fanciness, but if you don't need that and/or you've got some unwieldy subset of files to transfer - a situation the GUI-style approach makes light work of - then it comes in handy.)
http://www.catonmat.net/blog/unix-utilities-pipe-viewer/
It would be nice for cp and mv to just have built-in progress bars (only active in interactive mode, etc).
Here's the POC if anyone would like to take it further: http://anthias.sourceforge.net/
tar c -C /tmp/source . | pv | tar x -C /tmp/dest
you can also pass an approximated size of your source to pv, however the tar output will be slightly bigger.
A bit clumsy, but it shouldn't be hard to write a little script to do it.
Anyway, if cp -R had a progress bar it would behave the same way, i.e. it would have first to recursively stat the source the same way as du does, and only then it could start reporting a completion percentage.
And did you really just reinvent pkill?
I had a 2TB drive turn up five figure error rates (Raw Read Error rate ended up at 90k - when I started, it was already no longer possible to mount it, but it did show up in /dev) and thought I had lost an entire year of family pictures (mea culpa on not having a backup, of course). It took four months, 24/7 of meticulous work, but it ended up giving me a near perfect copy to an identical drive (save for ~20kb of truly dead sectors).
Amongst many other features, it has a logfile where it keeps track of the overall process - so that it can be killed or paused and restarted later.
I'm not too familiar with what file libs or utils can be used to handle this as the author says this relies on a linux specific header file and tool.
See https://github.com/Xfennec/cv/issues/6
Try: /bin/cp bigfile bigfile2
I've been using patched copies of coreutils to do the same thing, this is much better.
By the way, if you ever need to quickly spy on rsync you can try this:
but there is a chance cv will work with rsync too and be more helpfulhttps://chris-lamb.co.uk/posts/can-you-get-cp-to-give-a-prog...
(Sorry, really bad joke...)
http://powerline.readthedocs.org/en/latest/overview.html