Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
tmpfs ~/.cache cleaner daemon-script idea, to clean RAM space while trying to minimize SSD writes
Posted 10-27-2020 at 07:20 AM by the dsc
Updated 11-01-2020 at 03:45 AM by the dsc (maybe grammar or worse, maybe style)
Updated 11-01-2020 at 03:45 AM by the dsc (maybe grammar or worse, maybe style)
In line with the idea of reducing how much it's written on SSD, some people suggest using tmpfs for lots of things, one of them can be the ~/.cache directory. Which must be implemented in a per-user basis or with some pre-mount script that would do such tmpfs mounts before each user login. But regardless, the point is that they may spare the SSD, but not the RAM, obviously. If you quit a cache-heavy program, its cache would still be there, leaving other programs you're running with less RAM to use. Possibly even then forcing the OS to write things to the swap partition (if that's not completely disabled, which some people do), which would then be a counterproductive scenario in more than one aspect.
It seems that a reasonable solution could be some script-daemon that periodically checks whether the main programs are running and removes their subdirectories at ~/.cache, when those exist. Somewhat like this:
For programs that more fortunately use the process name for its cache subdirectory, then it perhaps could be done in a secondary/internal loop like:
It seems that a reasonable solution could be some script-daemon that periodically checks whether the main programs are running and removes their subdirectories at ~/.cache, when those exist. Somewhat like this:
Code:
#!/bin/bash while true ; do if ! pgrep someprogram ; then [[ -e ~/.cache/someprogramscachedirwithadifferentname ]] && rm -rf ~/.cache/someprogramscachedirwithadifferentname fi sleep 5m done
Code:
for program in processA processB processC processD ; do if ! pgrep ${program} ; then [[ -e ~/.cache/${program} ]] && rm -rf ~/.cache/${program} fi done
Total Comments 0