Last active
November 16, 2015 21:20
-
-
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
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one-liner does pretty much the same (less flexible though):
find /mnt/SonosSpeak -name "RINCON*" ! -atime -75d -exec rm -v {} ;