Using -mtime
does:
find ~/.cache -depth -type f -mtime +100 -delete
While we’re at it, here’s my housekeeping stuff. I keep it in a shell script that can be run all at once for convenience, but it’s also around for reference if I only want to perform a specific task.
# Vacuum journals
sudo journalctl --vacuum-size=500M && sudo journalctl --vacuum-time=7d
# Remove all uninstalled packages
sudo paccache -rvuk0
# Remove old installed packages, leave 3
sudo paccache -rvk3
# Clean yay cache
yay -Sc -a
# Clean pamac build cache
pamac clean -bv
# Clean temporary build files
rm -rf ~/{.bundle,.cargo,.cmake,.dotnet,.electron,.electron-gyp,.gem,.gradle,.lazarus,.node-gyp,.npm,.nuget,.nvm,.racket,.rustup,.stack,.yarn} || true
rm -rf ~/.cache/{electron,electron-builder,go-build,node-gyp,pip,yarn} || true
sudo rm -rf ~/go || true
# Find files not owned by any package
sudo lostfiles
I have a Pacman hook for detecting orphans:
/etc/pacman.d/hooks/orphans.hook
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *
[Action]
Description = Checking for orphaned packages...
When = PostTransaction
Exec = /usr/bin/bash -c "/usr/bin/pacman -Qtd || /usr/bin/echo '=> No orphans found.'"