Find and fills all available free space in root dir.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ROOT=$1 | |
PORT=$2 | |
DELETE=$3 | |
free_space () { | |
FREE_SPACE=$(df $1 | awk '{print $4}' | tail -n 1) | |
#echo $FREE_SPACE | |
echo $(($FREE_SPACE/1048576)) | |
} | |
for DIR in $ROOT/*/; do | |
cd $DIR | |
while [ "$(free_space $DIR)" -gt 104 ] | |
do | |
echo "Listening in $DIR - $(free_space $DIR)G Free" | |
nc -p $PORT -l | tar -x | |
echo "Plot saved in $DIR" | |
if [[ "$DELETE" == "true" ]]; then | |
ls plot-k32-2021-0[0-6]*.plot | head -n 1 | xargs rm -- | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment