Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FHEM: Cleans up SONOS Speak cache files. Files which have not been accessed(=played) during the last 75 days will be deleted
#!/bin/bash
FILES=`ls /mnt/SonosSpeak/RINCON*`
CURRENTTIME=`date +"%s"`
PASTDAYS=75
THESHOLDATIME=`expr $CURRENTTIME - $PASTDAYS \* 24 \* 60 \* 60`
echo -e "Cleaning up all files older than $PASTDAYS days ...\n\n"
for f in $FILES
do
FILEATIME=`stat -c "%X" $f`
if [[ "$FILEATIME" < "$THESHOLDATIME" ]]; then
echo "cleaned up $f: last access on `stat -c "%x" $f`"
rm $f
fi
done
@jpawlowski
Copy link
Author

jpawlowski commented Nov 16, 2015

This one-liner does pretty much the same (less flexible though):
find /mnt/SonosSpeak -name "RINCON*" ! -atime -75d -exec rm -v {} ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment