coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: progress bar in cp


From: Дмитрий Ильин
Subject: Re: progress bar in cp
Date: Wed, 10 Aug 2011 00:59:33 +0400

> 
> Have you considered using rsync?
> Is there some reason you require this functionality in cp?

Rsync is not in coreutils and is not always installed.

Yes you can use rsync, use pv with pipe, use dd or any other way to copy files.
But people are used to type 'cp' when they want to copy file.
And Ctrl+T to show what file is coping now and % left would be nice.

Lets look at MacOS X 'cp'

First i will make big file using dd and press Ctrl+T 3 times during process.

macbook:~ dilyin$ dd if=/dev/zero of=big.file bs=1m count=1000
load: 0.65  cmd: dd 32844 running 0.00u 0.29s
188+0 records in
188+0 records out
197132288 bytes transferred in 0.867653 secs (227201787 bytes/sec)
load: 0.65  cmd: dd 32844 running 0.00u 0.42s
285+0 records in
284+0 records out
297795584 bytes transferred in 1.327377 secs (224348937 bytes/sec)
load: 0.65  cmd: dd 32844 uninterruptible 0.00u 0.99s
734+0 records in
733+0 records out
768606208 bytes transferred in 3.518059 secs (218474507 bytes/sec)
load: 0.65  cmd: dd 32844 uninterruptible 0.00u 1.29s
958+0 records in
957+0 records out
1003487232 bytes transferred in 4.627076 secs (216872870 bytes/sec)
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 4.825880 secs (217281831 bytes/sec)

I can see current speed and how much have been written at any time.
(210Mb/s write is SSD)
FreeBSD has same feature and this interactivity is VERY useful when testing HDD 
speeds and for many other things.

Ok now lets do the same on FreeBSD box
I write 100mb file and press Ctrl+T 3 times

address@hidden ~]$ dd if=/dev/zero of=big.file bs=1m count=100 
load: 0.00  cmd: dd 88698 [wdrain] 0.00u 0.29s 1% 1740k
19+0 records in
18+0 records out
18874368 bytes transferred in 1.145493 secs (16477069 bytes/sec)
load: 0.00  cmd: dd 88698 [wdrain] 0.00u 0.55s 2% 1760k
89+0 records in
88+0 records out
92274688 bytes transferred in 4.100333 secs (22504194 bytes/sec)
100+0 records in
100+0 records out
104857600 bytes transferred in 4.464110 secs (23489026 bytes/sec)

Looks same as MacOS.
(23 Mb/s old SCSI hdd)

Note that I write 1m instead of 1M as in Linux's dd. I have asked on this list 
to add 'm' letter for megabyte in dd's get opt but was ignored.
FreeBSD users always type 1m and are confused when it doesn't work in linux.

Coreutils' dd will printout same info on SIGUSR1 but there is no way to send 
SIGUSR1 from keyboard, so i have to use killall -USR1 dd from second terminal. 
Convenient? NO!



Now lets copy file pressing Ctrl+T

macbook:~ dilyin$ cp big.file big2.file 
load: 0.47  cmd: cp 32595 uninterruptible 0.00u 0.27s
big.file -> big2.file  17%
load: 0.59  cmd: cp 32595 running 0.00u 0.62s
big.file -> big2.file  40%
load: 0.59  cmd: cp 32595 running 0.00u 0.89s
big.file -> big2.file  58%
load: 0.59  cmd: cp 32595 running 0.00u 1.21s
big.file -> big2.file  79%
load: 0.59  cmd: cp 32595 running 0.00u 1.47s
big.file -> big2.file  96%

See? we got file name being copied, percent and time passed. Great!

Now FreeBSD

address@hidden ~]$ cp big.file big1.file
load: 0.05  cmd: cp 89581 [wdrain] 0.00u 0.20s 0% 792k
big.file -> big1.file  36%
load: 0.05  cmd: cp 89581 [wdrain] 0.00u 0.27s 1% 812k
big.file -> big1.file  52%
load: 0.05  cmd: cp 89581 [runnable] 0.00u 0.46s 1% 812k
big.file -> big1.file  95%

Very similar with minor differences.

FreeBSD also goes even farther reporting system load and current process state 
on Ctrl+T even in program doesn't support it! Macos doesn't have it.

What linux can offer to interactively monitor cp/mv/install? Nothing! Well… Use 
rsync)

Of cause implementing SIGINFO or at least SIGUSR1 from Ctrl+T will require 
tinker with kernel, but what can we do?

1. Add similar printout for cp/mv/install on SIGUSR1
2. Add option to display progress bar for every file copied and file name too. 
It's much easier to implement then new signals in kernel tty.
3. PLEASE Add 'm' synonym of 'M' in 'dd'. Backend library supports both just 
add one letter in get opt allowed options list.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]