Script Ubuntu - Check Disk Space -

Good Morning,

could someone help me please.
I have a plotting rig for bladebit. The only issue I have the buffer disks running all time full … so I would look for a script that checks disk space - if disk space >220 GB then run a blade bit plot.

Im a newbie in ubuntu and looking for help!

Thank you very much!

All the best

How about to use

ls | wc -l 

to count number of plot files?


I was plotting some time to local hard drive and was then moving to external HDDs. I was mounting those to a partition that contained “external” in the name.
There I moved only as much plots as space allowd. This was done like this:

cd /farming/; 
for i in $(ls *.plot); do 
   echo $i; 
   size=$(ls -l $i|awk '{print $5}'); 
   availspace=$(df -B 1| grep external|awk '{print $4}'); 
   if [ "$availspace" -gt "$size" ]; then 
      echo "Enough space found on destination (/home/myuser/external): $availspace"; 
      mv $i ~/external/$i; 
      echo "Not enough space left: $(df -h | grep external)"; 

The main part if doing df -B (in bytes) and then grepping string “external”. Then using AWK I printed just the value found in the output.
Size of plot that was to be moved was calculated before that.

Actually, I was running it as a “one liner”, but here it’s broken into several lines for (some) readability.

Hope it helps.