Skip to content

Instantly share code, notes, and snippets.

@jpawlowski
Last active November 16, 2015 21:20
Show Gist options
  • Save jpawlowski/689d1cf74334488cd127 to your computer and use it in GitHub Desktop.
Save jpawlowski/689d1cf74334488cd127 to your computer and use it in GitHub Desktop.
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

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