autoremoval dvr files ftp

por | 25 abril, 2019
partition=/dev/root
imagedir=/dvr/files
num_files=200

if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]];
then
    echo "Cleaning disk"
    find $imagedir -type f | sort | head -n $num_files | xargs -r rm -rf;
fi;
Make the script executable.

chmod +x /home/pi/autoremoval.sh
Initiate a cronjob, and select the nano editor.

crontab -e
Append following line, to execute the autoremoval.sh script every 5min.

*/5 * * * * /bin/bash /home/pi/autoremoval.sh