Skip to content

unRAID Delete Empty Cache Directories⚓︎


Delete Empty Cache Directories⚓︎

I found in unRAID 6.8 the cache had many directories which were empty. This was due to the mover not cleaning up once it moved files to the data disks. Minor annoyance to me, but easy to clean.

Bash
1
2
3
4
5
6
7
#!/bin/env bash
#name=delete_empty_cache_directories
#description=dremy - Delete empty directories from the cache for shares which have shareUseCache set to 'yes'
#arrayStarted=true

echo "Searching for (and deleting) empty directories in the cache"
find $(grep -l 'shareUseCache="yes"' /boot/config/shares/* | awk -F'/' '{print $5}' | awk -F'.' '{print "/mnt/cache/"$1}') -type d -empty -delete