LoginSignup
14
14

More than 5 years have passed since last update.

cpコマンドの進捗状況をチェックする

Posted at

コピー中にあとどれくらいか知りたい時があるんです、
特にcp -vを忘れた時に有用

Xfennec/progress
調べたら、こちらのprogressを使うと簡単にできます

ダウンロード

git clone https://github.com/Xfennec/progress.git
Initialized empty Git repository in /home/kubor/src/progress/.git/
remote: Counting objects: 279, done.
remote: Total 279 (delta 0), reused 0 (delta 0), pack-reused 279
Receiving objects: 100% (279/279), 206.50 KiB | 111 KiB/s, done.
Resolving deltas: 100% (142/142), done.

コンパイル

cd progress; make
cc -g -Wall -D_FILE_OFFSET_BITS=64 -c progress.c
cc -g -Wall -D_FILE_OFFSET_BITS=64 -c sizes.c
cc -g -Wall -D_FILE_OFFSET_BITS=64 -c hlist.c
cc -Wall progress.o sizes.o hlist.o -o progress -lncurses -lm

usage

./progress -h
progress - Coreutils Viewer
---------------------
Shows running coreutils basic commands and displays stats.

Commands monitored by default:
cp mv dd tar gzip gunzip cat grep fgrep egrep cut sort xz md5sum sha1sum sha224sum sha256sum sha384sum sha512sum adb 

Usage: ./progress [-qdwmM] [-W secs] [-c command] [-p pid]
  -q --quiet              hides all messages
  -d --debug              shows all warning/error messages
  -w --wait               estimate I/O throughput and ETA (slower display)
  -W --wait-delay secs    wait 'secs' seconds for I/O estimation (implies -w, default=1.0)
  -m --monitor            loop while monitored processes are still running
  -M --monitor-continous  like monitor but never stop (similar to watch ./progress)
  -c --command cmd        monitor only this command name (ex: firefox)
  -p --pid id             monitor only this process ID (ex: `pidof firefox`)
  -v --version            show program version and exit
  -h --help               display this help and exit

監視対象は結構いろいろあるみたいですね

cp mv dd tar gzip gunzip cat grep fgrep egrep cut sort xz md5sum sha1sum >sha224sum sha256sum sha384sum sha512sum adb

シンボリックリンクは、cvコマンドとしてリンクしておきます
coreutils viewerとのことですし

ln -s ~/src/progress/progress ~/bin/cv

cpで大きなファイルをコピー中に実行してみる
せっかくなので別セッションで実行してみます

cp huge_genome_R1.fastq /mnt/usb/

cpが別セッションで実行中に、新しく接続したセッションで監視してみます

cv
[32720] cp /home/oryza/exome/fastq/huge_genome_R1.fastq  /mnt/usb/ 44.4% (698.5 MiB / 1.5 GiB) 50.9 MiB/s eta 0:00:17

ファイルはフルパスで展開されるのですね
ちなみに-mオプションをつけるとリアルタイム監視できます
watch cvしてるのと同じでしょうか

READMEを読むと/procを読んでいるらしいです

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14