So here's a simple bash script that's mostly taken from stackoverflow that I''ve proven works flawlessly. The two zmaudit.pl are intentional, for some reason it needs to be called twice to actually cleanup the folder.
Code: Select all
#!/bin/bash
usage=$(du -sb /var/cache/zoneminder/HighResCamEvents | cut -d $'\t' -f 1)
max=10000000000
if (( usage > max ))
then
find /var/cache/zoneminder/HighResCamEvents -maxdepth 5 -type f -printf '%T@\t%s\t%p\n' | sort -n | \
while (( usage > max )) && IFS=$'\t' read timestamp size file
do
rm -- "$file" && (( usage -= size ))
done
fi
zmaudit.pl
zmaudit.pl