Linux Blog

Monitor Disk Usage for Large Copies

Filed under: Shell Script Sundays — Owen at 12:24 pm on Sunday, August 23, 2015

Note: There are probably better ways of doing this. I am currently coping a decent amount of data using rsync between a NAS drive and a locally mounted USB drive and wanted to monitor the process.

This works for the local drive:

owen@thelinuxblog:~$ df -h /dev/sdc1 | cut -d \  -f 11 | tail -n 1

I started figuring out the way to display the NAS total usage, which looks something like this:

df -h |grep NAS2 | cut -d % -f 1 | cut -d \  -f 35- | cut -d \  -f 1

Which is fine, but really is not needed and is bit overkill when I know the total amount that is going to get copied, so I simplified it down a bit to look like this:

owen@thelinuxblog:~$ echo `df -h /dev/sdc1 | cut -d \  -f 11 | tail -n 1` of 100G
41G of 100G

Then I wrote a loop to print out the usage every 5 minutes (300 seconds) and the date.

owen@gibson:~$ while [ $(echo `df -h /dev/sdf1 | cut -d \  -f 11 | tail -n 1` | sed 's/G//') -lt 100 ]; do echo `df -h /dev/sdf1 | cut -d \  -f 11 | tail -n 1` of 100G `date`; sleep 300; done;

This was a quick and dirty way of monitoring progress while passing time and now I’m able to keep an eye on things.


Comment by robert wilber

March 7, 2016 @ 1:18 am

I love anything Linux related. I am running Ubuntu 12.04 Cinnamon remix. I can upload a photo if you like.

Comment by java training in coimbatore

April 29, 2016 @ 2:32 am

Is there any way to automate disk usage check?

Comment by disaster recovery

May 18, 2016 @ 1:33 pm

Thats great – I need to pass this onto a colleague as this came up the other day! Thanks a lot!

Trackback by

November 7, 2016 @ 3:28 pm

The Linux Blog » Page not found

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>