A command line utility to visualize how fast a file is growing?
tail -f file | pv > /dev/null
But beware that it involves acually reading the file, so it might consume a bit more resources than something that watches just file size.
progress
(Coreutils progress viewer) or recent versions of pv
can watch a file descriptor of a particular process. So you can do:
lsof your-file
to see what process ($pid
) is writing to it and on which file descriptor ($fd
), and do:
pv -d "$pid:$fd"
or:
progress -mp "$pid"
I have a little perl script that I put in my bash environment as a function:
fileSizeChange <file> [seconds]
Sleep seconds defaults to 1.
fileSizeChange() {
perl -e '
$file = shift; die "no file [$file]" unless -f $file;
$sleep = shift; $sleep = 1 unless $sleep =~ /^[0-9]+$/;
$format = "%0.2f %0.2f\n";
while(1){
$size = ((stat($file))[7]);
$change = $size - $lastsize;
printf $format, $size/1024/1024, $change/1024/1024/$sleep;
sleep $sleep;
$lastsize = $size;
}' "$1" "$2"
}