If your using cp or tar or scp or cat|ssh to transfer files chances are you dont have a progress bar or even have a clue as to how fast your volume is changing. Of course you can manually run this:

For du date +%s; du -B1;  or for df date +%s; df -B1;  (to get date in epoch seconds and volume size in bytes) and do the math yourself with a couple of time spaced readings (say 10 seconds or a few minutes or hours apart) to get an idea of how fast your going.  The -B1 argument asks for output to be of blocksize 1 (1 byte) meaning everything is reported in Bytes (like wise -B1024 and -Bk report the same numbers). From the man page of du & df:

-B, –block-size=SIZE use SIZE-byte blocks

SIZE may be (or may be an integer optionally followed by) one of fol- lowing: kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

The formula is as simple as it gets:

SpeedInBytesPerSecond = (CurrentByteSize-OldByteSize) / (CurrentTimeInEpochSeconds-OldTimeInEpochSeconds)

ds = (s1-s0)/(t1-t0)

Here are 4 scripts that are copy pasteable. First you need to edit the variables mentioned in the comments. Then you just copy paste the commands. The manual ones you repeat while the automatic ones you dont have to repeat as the looping algorithm takes care of that for you.

df auto, df manual, du auto, df manual

You can use the du scripts if you want to monitor the rate of change of its size. If you want to monitor a whole volume you can use df. Note that if a folder has many subfolders and files, du will take a while to calculate so measuring rate of change with du is not recommended in that scenario, instead measure with df – however it will only be useful if thats the only thing transfering into the server. both of these scripts can be used to monitor how quick space is being freed up (space being freed up is a negative speed)

How to use these scripts:

1) pick the script you wish to use based on if you want auto loops or manual looping (when you repeat the command you get the output). Remember folders with many files will take a moment with du. Where as df will give you an overall rate of change of the entire volume rather than a folder.

2) Copy the script from here and paste into your notepad for editing. Preferably something that supports linux line endings such as Notepad++(although that doesnt really matter as the scripts are one line big anyways – if you dont include the header comment)

2) fill out the variable MNTofDEVICEtoMONITOR, INTERVAL or FOLDER,INTERVAL (the none-looping scripts dont have an INTERVAL variable)

3) Select the edited script

3) Copy the edited script to your clipboard by selecting it and pressing CONTROL-C

4) Paste the script and hit enter to run the script. IF your using putty you simply need to paste by right clicking with the mouse inside of the putty terminal. Note that clicking enter is optional and not needed. If you also selected a newline character (they are invisible but signify and emulate the press of an ENTER key) then you wont need to press ENTER (but if you do it wont damage anything, you will just have an extra blank line on the output). If you didnt slect a newline character when you copied the text you will need to press ENTER after you paste the output into your shell/terminal.

DF

DU

DU – OLD – ARCHIVE (only manual version)

…the end…

Leave a Reply

Your email address will not be published. Required fields are marked *