Bash Script to Monitor and delete old "OG" plots to make room for new NFT plots


This script uses crontab to monitor a folder containing the old non-poolable plots for Chia, aka OG plots. This only works if you have kept different types of plots in separate folders. The script does not check the plot type so be warned that if you use a folder with NFT plots, those will be deleted also. The script will delete plots when the amount of free space drops below 110,000,000 (110 GB). 



Here is the script, called "drivemon.sh".

#!/bin/bash
drv=$1
free=`df --output=target,avail $drv | grep -v "Mount" | cut --fields 2 --delimiter=\ `
if [[ $free -lt 110000000 ]]; then
# if free space is less than 110GB _and_ there are 
# OG plots on the drive, delete the oldest plot.
ogcount=`ls $drv/*.plot | wc -l`
if [[ $ogcount -gt 0 ]]; then
    rm "$(ls -t $drv/*.plot | tail -1)"
  fi
fi


And the entry into crontab. (adjust the drive to match your needs)

crontab -e

5,10,15,20,25,30,35,40,45,50,55 * * * * ~/mycode/drivemon.sh /mnt/hdd-b


You may need to make the script executable for crontab.

chmod +x drivemon.sh

Comments

Popular posts from this blog