Share your knowledge at the LQ Wiki.
Go Back > Blogs > linux-related notes
User Name


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.
Rate this Entry

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)
Tags hack, script, ssd, tmpfs

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:


while true ; do

if ! pgrep someprogram ; then

[[ -e ~/.cache/someprogramscachedirwithadifferentname ]] && rm -rf ~/.cache/someprogramscachedirwithadifferentname


sleep 5m

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:

for program in processA processB processC processD ; do

if ! pgrep ${program} ; then

[[ -e ~/.cache/${program} ]] && rm -rf ~/.cache/${program}


Posted in Uncategorized
Views 147 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 10:53 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration