Reminder to clear your ~/.cache folder every now and then
from Zangoose@lemmy.world to linux@lemmy.ml on 03 Dec 2023 00:30
https://lemmy.world/post/9065720

Alt Text

A screenshot of a file manager preview window for my ~/.cache folder, which takes up 164.3 GiB and has 246,049 files and 15,126 folders. The folder was first created about 1.75 years ago with my system

#linux

threaded - newest

dog_@lemmy.world on 03 Dec 2023 01:59 next collapse

Question, could you have cron/crontab do it monthly or something? Do it monthly meaning delete everything in ~/.cache every month or so?

[deleted] on 03 Dec 2023 02:34 next collapse

.

BaroqueInMind@kbin.social on 03 Dec 2023 04:58 next collapse

This is the good shit I miss from reddit. Thank you for posting a systemd service config, I'm going to implement this.

Zangoose@lemmy.world on 03 Dec 2023 06:24 collapse

Thanks for this! I’ve been meaning to start getting into learning more about systemd and making services, this is super detailed and gives me a pretty good starting point!

cmnybo@discuss.tchncs.de on 03 Dec 2023 02:38 next collapse

You could have a cronjob run something like find /home/user/.cache -type f -atime +30 -delete, which would find files that haven’t been accessed in the last 30 days and delete them. Make sure your home partition is not mounted with the noatime option though.

Zangoose@lemmy.world on 03 Dec 2023 02:55 next collapse

I just found this today, I don’t really know anything about cron jobs but this will probably incentive me to learn lol

SuperIce@lemmy.world on 03 Dec 2023 03:09 collapse

Did you happen to see which subdirectory was using up this much space? I don’t think I’ve ever seen .cache go above 10GB, so this may be a bug in a piece of software you use.

Bronco1676@lemmy.ml on 03 Dec 2023 04:39 next collapse

Running ncdu on it would’ve been cool to see.

Zangoose@lemmy.world on 03 Dec 2023 06:46 collapse

<img alt="" src="https://lemmy.world/pictrs/image/1db16aff-0fdf-421a-84d4-77091efdea1a.png">

<img alt="" src="https://lemmy.world/pictrs/image/723e165b-7648-48d1-92c5-5e655172326d.png">

Looks like yay is storing every previous binary for AUR bin packages (also excuse the unreadable terminal theme, it doesn’t play very well with a lot of TUI apps unless they support custom theming)

neonred@lemmy.world on 03 Dec 2023 07:37 next collapse

Wow, I’ve never seen something like this.

Is it" allowed"? I mean, there are quotas for user homes.

Bronco1676@lemmy.ml on 03 Dec 2023 18:55 collapse

You should run yay -Sc from time to time. This cleans a) your pacman cache (which is normally done by executing pacman -Sc) b) your AUR build cache, which is what’s taking up 160GB. But this one seems rather unusual, I use paru (which also has the command paru -Sc), so I can’t really tell if this is normal with yay.

The command also asks you for every directory if you want to delete it or not, so it’s completely save to run that command.

Zangoose@lemmy.world on 03 Dec 2023 21:30 collapse

Something I noticed was that it was mostly the binary packages that were taking up so much space, it may be because of how yay stores the programs (does it use git?), the ones that were compiled from source code usually took up the least amount of space, while the binary programs were the ones taking up tens of gigabytes

Bronco1676@lemmy.ml on 03 Dec 2023 22:05 collapse

Indeed, yay utilizes the AUR, which essentially serves as a Git repository for each package. These repositories typically include a PKGBUILD file and a .SRCINFO file, along with possible additional files like patches, desktop, or service files.

For example, take a look at IntelliJ Ultimate: [aur.archlinux.org/cgit/aur.git/tree/?h=intellij-i…]. It contains the .SRCINFO and PKGBUILD, as well as a .desktop file. These files themselves do not occupy much space.

The PKGBUILD specifies the sources for dependencies. For instance:

source=("https://download.jetbrains.com/idea/ideaIU-$pkgver.tar.gz"
        "jetbrains-idea.desktop")

The PKGBUILD is essentially a Bash script with predefined functions and variables. You can learn more about it here: [wiki.archlinux.org/title/PKGBUILD].

This script primarily downloads and extracts the tar file. In this specific case, it only relocates the files to their intended installation locations, like moving the desktop file to /usr/share/applications.

With such packages, there’s a possibility of wasting significant space since the tar file is downloaded and possibly retained in the cache.

However, other packages, especially those compiled from source, usually involve Git clones. These clones bring the Git repository into a subdirectory of the already cloned AUR package Git repo. Some might also have source tarballs. These types of packages generally do not consume much space in the cache, as they are often just text files, like C source code or Python scripts. These packages frequently rely on external libraries and packages, which are not included in this package’s cache.

While binary packages often bundle all necessary libraries and other components in their source tarballs.

The AUR cache is mostly beneficial if you’re rebuilding the same version or can reuse components from a previous version. For example, a package might depend on a large, static file that doesn’t change often.

In Paru, I’ve enabled the “CleanAfter” option to prevent my cache from overflowing. Given my relatively fast internet speed, redownloading large files isn’t a major concern for me.

Zangoose@lemmy.world on 03 Dec 2023 06:22 collapse

Haven’t deleted it yet actually, looks like most of it is from yay

bizdelnick@lemmy.ml on 03 Dec 2023 08:19 next collapse

Don’t. You don’t need to clean it unless cache of some buggy program grows uncontrollable.

sebsch@discuss.tchncs.de on 03 Dec 2023 09:54 collapse

Just mount it into your RAM

just_another_person@lemmy.world on 03 Dec 2023 02:02 next collapse

This particular folder caches many things from various package managers. Won’t hurt to clear, but will fill up again. Maybe consider not using caches when engaging such things.

elbarto777@lemmy.world on 03 Dec 2023 03:17 next collapse

How?

just_another_person@lemmy.world on 03 Dec 2023 03:33 collapse

Depends on the package manager. Check options for whatever you’re running.

ryannathans@aussie.zone on 03 Dec 2023 03:45 next collapse

Can hurt to clear, there’s a lot more than just package managers using it

just_another_person@lemmy.world on 03 Dec 2023 04:32 collapse

It’s a cache folder. Created by the distro. They labelled it as such because it’s cache, and can be considered ephemeral. It won’t do any permanent damage to anything unless you’ve accidentally been using it for something else.

bizdelnick@lemmy.ml on 03 Dec 2023 08:17 collapse

Package managers don’t use this directory as well as any other subdirectory of user’s home.

just_another_person@lemmy.world on 03 Dec 2023 13:56 collapse

Could have fooled me, because it’s certainly the default for things like brew, flatpak, mpm, and pip. Looks like npm and maven use it on certain Debian based distros as well. I’m betting more of the immutable distros use that directory as well vs something in /var/cache.

bizdelnick@lemmy.ml on 03 Dec 2023 14:34 collapse

Ah, sorry, I thought about system package managers like apt, dnf, zypper etc.

nick@midwest.social on 03 Dec 2023 02:45 next collapse

That’s not very cache money of you

Jinn@sh.itjust.works on 03 Dec 2023 03:05 next collapse

This is one of those things that makes me shake my head about Linux. It’s these small dumb problems that make Linux inaccessible to the common person.

SuperIce@lemmy.world on 03 Dec 2023 03:07 next collapse

Not really. I’ve never seen .cache get bigger than 10GB, which is about how big the temporary files in Windows get if you never clean them.

[deleted] on 03 Dec 2023 06:38 next collapse

.

Zangoose@lemmy.world on 03 Dec 2023 06:52 collapse

It ended up being yay storing binaries from previous versions of AUR packages, definitely depends on the distro/usage but for arch-based it definitely clears up a lot of storage

[deleted] on 03 Dec 2023 03:09 next collapse

.

cmnybo@discuss.tchncs.de on 03 Dec 2023 04:58 collapse

I’ve never seen any of my ~/.cache directories get more than a few GB either and I never bother to clean them.
I am curious what OP was doing that used that much space though. That’s certainly not typical.

Zangoose@lemmy.world on 03 Dec 2023 06:44 next collapse

It was AUR packages from yay. I’m a CS major into gaming and emulation so there are a decent amount of programming build tools from the aur that I had, it looks like most of it is coming from storing all of the binaries from AUR packages, as intelliJ ultimate takes up 50 GiB, proton-ge-custom takes up 31 GiB, and Yuzu emulator takes up 16 GiB.

aleq@lemmy.world on 03 Dec 2023 09:54 collapse

I get the same all the time. OP reminded me to check today and Jetbrains toolbox had cached a lot of downloads that took up 42 GB in total. yarn folder with 2.3 GB. bazel folder with 15 GB (apparently used for building Anki),7 GB paru clones.

All in all it added up to 82 GB.

NegativeLookBehind@kbin.social on 03 Dec 2023 03:27 next collapse

Yes because other operating systems never have any small annoying issues.

Jinn@sh.itjust.works on 03 Dec 2023 04:08 collapse

They do have small annoying issues. This is not one of them. This is something that would completely baffle a non-tech literate person. They’d just observe their computer becoming slow or not having space and say “well, Linux must have broken my computer.”

kglitch@kglitch.social on 03 Dec 2023 04:33 next collapse

Have you checked your C:\windows\temp folder lately?

atzanteol@sh.itjust.works on 03 Dec 2023 05:17 next collapse

Oh yeah, you never hear such complaints about Windows or MacOS.

BTW can you recommend any good tools to cleanup my registry?

ik5pvx@lemmy.world on 03 Dec 2023 06:14 collapse

And don’t forget to defrag, while you are at it.

kariboka@bolha.forum on 03 Dec 2023 14:10 collapse

Windows auto defrag now though. Dont hate me I love my Linux.

d3Xt3r@lemmy.nz on 03 Dec 2023 05:30 next collapse

FYI, Windows doesn’t have any feature either to automatically clear all of it’s temp folders (%TMP%, C:\Windows\Temp, C:\Windows\Panther), plus several other folders where orphaned files are often leftover, such as C:\Windows\Installer, C:\Windows\CSC, and various folders and cache files in your AppData\Local etc, to name a few off the top of my head.

I used to be a Windows sysadmin for a long time, and let me tell you, HDDs becoming completely full due to cache/temp files is very much a problem in Windows.

Infiltrated_ad8271@kbin.social on 03 Dec 2023 06:50 next collapse

This has not been the case since at least w10, it has a tool to automatically clean several temp files and recycle bin.

d3Xt3r@lemmy.nz on 03 Dec 2023 18:20 collapse

If you’re talking about the Storage Sense feature - it sucks. It only clears a handful of well-known locations, but it doesn’t touch any of the orphaned content in C:\Windows\Installer, or the CSC or the old Panther folders from upgrades, not to mention several other files and folders in AppData. As I’ve said before, I’ve been a Windows sysadmin (until last year infact) managing over 20,000 devices, we’ve had Storage Sense on, but it’s been mostly useless - to the point that I ended up writing own cleanup script and set it to run before we pushed out a new Windows feature update, because otherwise we’d get several devices which failed to update due to the disk being full.

Infiltrated_ad8271@kbin.social on 03 Dec 2023 20:30 collapse

I think it's that one. I certainly won't say it's a panacea, but I assume it would have solved the OP's case.

Astaroth@lemm.ee on 03 Dec 2023 08:57 collapse

Guess what I found in /home/{user}/.wine/drive_c/users/{user}/Temp, 10GB of log files. Although 9GB was from one time when I used Cheat Engine and I don’t know what really happened tbh besides it causing a OOM crash.

It created a 9GB sized file called ADDRESSES.TMP, I never considered checking for temp files in .wine before. And I guess I should be checking all the prefixes created by Steam games as well…

fluffyb@lemmy.fluffyb.net on 03 Dec 2023 06:00 collapse

I once had a huge 20ish GB file in windows I could not get rid of, move, or delete. It was related to hibernation or something like that… Even though I had hibernation disabled and no amount of googling could get rid of the file.

This is something that would completely baffle a non-tech literate person. They’d just observe their computer becoming slow or not having space and say “well, my computer just broke itself better throw it in the trash and get a new one”

UndercoverUlrikHD@programming.dev on 03 Dec 2023 09:11 next collapse

I’ve seen similar issues in appdata on windows when a program is poorly configured and simply grow its logs to ridiculous sizes. It’s an issue with a program utilising that folder, not the os.

JubilantJaguar@lemmy.world on 03 Dec 2023 14:50 next collapse

The hate you’re getting for this is so revealing and depressing. It basically proves you right.

To the haters: where is the factual problem with this personal opinion? Have you considered making a counter-argument instead, instead of simply lashing out with the downvote button like spoiled infants? This kind of tribal pile-on really pisses me off. You are literally censoring an opinion expressed in good faith - downvotes hide comments and reduce reputation. All while offering no rebuttal, no ideas of your own, nothing. Nice work.

Jinn@sh.itjust.works on 03 Dec 2023 14:58 next collapse

It is what it is. I’ve been involved in Linux communities long enough to know not to take stuff like this personally.

On Reddit we saw constant posts about why Linux isn’t more popular but no one ever talks about all the dumb little issues that the distros have because of a slight lack of polish. Those little issues make the distros seem cheap compared to the polish of something like Windows.

I’m always amused at the replies I get with things like “When I had Windows it literally caused my CPU to burst in to flames and my SSD shot my dog. Now I’m running Arch and it showed me last night’s winning lotto numbers.”

JubilantJaguar@lemmy.world on 03 Dec 2023 15:22 collapse

Ha! Yes I agree completely with all of that.

And with your point here. In this world of pocket touchscreens and voice AIs, where young people don’t even know what a file is any more, the geeks here are reminding each other to empty their .cache directory from time to time. I mean, do they have no self-awareness? Or perhaps they simply don’t care if nobody chooses to use Linux. That at least would be coherent, but if there are no new users then eventually the whole thing will just die.

Zangoose@lemmy.world on 03 Dec 2023 17:21 collapse

IMO I’d say the same thing about windows’s “Temp” folder though.

I agree that a lot of Linux isn’t user friendly but I’m also on a distro that is specifically supposed to be customized from the ground up (arch-based) using a tiling window manager which also involves configuring most things from the ground up. This isn’t a problem that most Linux users will likely have, but it is a problem that people may have if they are power users trying to have full control over their system (people who will be on a community about Linux). From what others in this thread have been saying, non-arch distros (and even arch with other aur helpers than yay) tend to have much smaller caches that get up to around 10Gb at most, which is also similar in size to what Windows’s temp directory uses.

This is a Linux community on a FOSS platform. This community is inherently going to be filled with more “geeky” people. Isn’t this what we signed up for? You make it seem like Linux was ever attracting people who weren’t these type of people to begin with. Computer science is still a growing field, and most sane computer science curriculums involve using POSIX terminal commands and by extension linux at some point. I’m a zoomer and can confirm, we’re not all as hopeless as you think we are. Linux will be fine even ignoring all of its corporate and government backing. And for people who don’t even know what a file is, they probably won’t know what Linux is in the first place. Even if they somehow have a system preconfigured with linux, their Ubuntu or Linux Mint install will probably be clearing the cache for them.

JubilantJaguar@lemmy.world on 03 Dec 2023 17:42 collapse

Some good points here, I stand partially corrected.

There are in fact 2 completely separate things that irk me. The biggest is the virtual lynching that is mass-downvoting. I’m sorry, I will never ever pardon the downvoting of opinions, I think it’s the illness of the social internet since the very beginning. See my many other recent comments for evidence of how strongly I feel about this.

The other issue is the actual one at hand! You’re right that this cache folder business does not really concern most ordinary users, even on Ubuntu. But actually, if even we geeks need to tell each other to “remember to do X every now and then”, I have enough of an IT mind to think “Why do we need to remember anything?! The tool should do this job for us!” These are “babysitting” chores and IMO on a decent OS there should be zero babysitting, it should be set up once and then it should work forever, with any tweaking optional.

the_sisko@startrek.website on 03 Dec 2023 16:59 collapse

Not a “hater” in terms of trying/wanting to be mean, but I do disagree. I think a lot of people downvoting are frustrated because this attitude takes an issue in one application (yay), for one distro, and says “this is why Linux sucks / can’t be used by normies”. Clearly that’s not true of this specific instance, especially given that yay is basically a developer tool. At best, “this is why yay sucks”. (yay is an AUR helper - a tool to help you compile and install software that’s completely unvetted - see the big red banner. Using the AUR is definitely one of those things that puts you well outside the realm of the “common person” already.)

Maybe the more charitable interpretation is “these kinds of issues are what common users face”, and that’s a better argument (setting aside the fact that this specific instance isn’t really part of that group). I think most people agree that there are stumbling blocks, and they want things to be easier for new users. But doom-y language like this, without concrete steps or ideas, doesn’t feel particularly helpful. And it can be frustrating – thus the downvotes.

JubilantJaguar@lemmy.world on 03 Dec 2023 17:26 collapse

Fair enough, tho personally I don’t see this “doom-y language” you see, I just see a slightly exasperated opinion expressed in good grammar and good faith.

But personally I don’t downvote people for their opinions, ever, as a matter of principle. It’s literally a form of censorship, given that it hides the comments. It leads straight to a deadening groupthink where dissenters are scared to open their virtual mouths. It creates a general aura of negativity and intolerance that helps nobody at all. Downvoting, as it is used by most people here and on the R-site, is an absolute scourge. If anything makes me leave this community, it will be this.

ProtonBadger@kbin.social on 03 Dec 2023 18:56 next collapse

Well, they're an Arch Linux user which is a special case. On Arch and derivatives it's the user's responsibility to manage the system so this doesn't happen, configure cleanup daemons, flush package managers, etc., alternatively it could also be a misbehaving application which would have to be reported. Arch is for hobbyists who likes to do this.

On other Linux distributions, Windows or macOS if this happens it's usually an application not properly managing its cache.

TheWoozy@lemmy.world on 09 Dec 2023 22:57 collapse

I’ve been running Linux as my primary OS since the late 90s and have never run into this problem.

SuperIce@lemmy.world on 03 Dec 2023 03:07 next collapse

I don’t think I’ve ever seen .cache get bigger than 10GB

SkyeStarfall@lemmy.blahaj.zone on 03 Dec 2023 03:31 next collapse

Depends on the distributions and default settings. In arch, by default, pacman doesn’t delete cache.

SuperIce@lemmy.world on 03 Dec 2023 03:50 collapse

Pacman’s cache isn’t in ~/.cache though, it’s in /var/cache. So whatever is taking up this much space isn’t the package manager.

That being said, I think the arch devs should add a config option to automatically delete old packages without having to run paccache manually and have it default to the last 2 versions of a package or so. It can grow quite big over time.

JustTesting@lemmy.hogru.ch on 03 Dec 2023 06:54 collapse

You can set a hook to do it automatically or use this, but I agree that this should be default behaviour

SuperIce@lemmy.world on 03 Dec 2023 06:56 collapse

You can also just do systemctl enable paccache.timer to automatically run paccache once a week.

Zangoose@lemmy.world on 03 Dec 2023 06:36 collapse

It looks like yay was storing AUR build files there, that folder took up about 160 of the 164GiB

SuperIce@lemmy.world on 03 Dec 2023 06:51 next collapse

You can use yay -Sc to clean the cache. It’ll also ask you if you want to clean the pacman cache, which I’m assuming you also haven’t cleaned (check the size of /var/cache/pacman).

30p87@feddit.de on 05 Dec 2023 17:03 collapse

One would just need to modify the pacman cache hook for yay. I’m too lazy tho.

bizdelnick@lemmy.ml on 03 Dec 2023 08:13 next collapse

If it is true, it is a bug in yay. Cashe should not grow without limit.

bizdelnick@lemmy.ml on 04 Dec 2023 21:04 collapse

It was reported twice as minimum. Seems that author does not care.

MonkderZweite@feddit.ch on 03 Dec 2023 12:35 next collapse

Shouldn’t it store that stuff in data-home or state-home? Pikaur compiles in cache and stores it in data-home after.

kattenluik@feddit.nl on 03 Dec 2023 15:30 collapse

You should try using paru, might be better off with it.

stepanzak@iusearchlinux.fyi on 03 Dec 2023 15:57 next collapse

Paru cache is huge and you have to delete it manually with something like paru -Sc i think

brakenium@lemm.ee on 03 Dec 2023 18:33 collapse

My update script handles mirrors, updates and cleans the cache automatically. I’d definitely recommend creating one. It’s aliased to sysupdate for me and I also check if it’s a debian or arch based distro so the command works on my servers and desktop

BaroqueInMind@kbin.social on 04 Dec 2023 05:26 next collapse

What is your update script? Where did you post it?

brakenium@lemm.ee on 04 Dec 2023 19:04 collapse

I don’t think I’ve posted it before, but here it is. If you use different utilities you’d have to swap those out. Also excuse the comments, I had GH Copilot generate this script

stepanzak@iusearchlinux.fyi on 04 Dec 2023 21:46 collapse

I highly recommend topgrade. You can add custom commands so clearing paru’s cache shouldn’t be a problem. I just do it by hand as I’m ok with it.

brakenium@lemm.ee on 05 Dec 2023 06:02 collapse

I’ve heard of tools like that, but this works fine for me. This way I’m not dependent on it being packaged for my distro and having to install it through other means. I’m fine running things manually, this is just for convenience

EddyBot@feddit.de on 03 Dec 2023 18:36 collapse

it doesn’t matter if you use paru, yay or heck makepkg if you are compiling packages with hilariously large sources like for example webbrowser (librewolf, brave, ungoogled-chromium, firedragon take each like ~30 GB) without pruning the build cache afterwards

Zangoose@lemmy.world on 03 Dec 2023 21:48 collapse

Something I noticed was that in this case it was mostly binary AUR programs taking up the space.

I think maybe since yay/AUR use cloned git repos, and old versions of binaries get stored in the git diff and then add up because different versions of the binary are basically like keeping multiple copies of it instead of just the changes to the source code.

conorab@lemmy.conorab.com on 03 Dec 2023 03:43 next collapse

Doesn’t Steam store the game library there?

Zangoose@lemmy.world on 03 Dec 2023 06:35 next collapse

No, .cache is similar to a temporary directory (or at least in theory) where important data isn’t supposed to be stored there, instead only temporary files that might speed things up (e.g. images in a browser or thumbnails in a file manager). In this case it looks like all of my AUR packages had their source files cached, which added up over the ~1.75 years that I’ve been running this distro

conorab@lemmy.conorab.com on 04 Dec 2023 01:22 collapse

Yep my bad! I mis-remembered .local/share/steam as . cache/share/steam. :)

CheesyFox@lemmy.world on 03 Dec 2023 09:55 collapse

it stores it in ~/.steam

conorab@lemmy.conorab.com on 03 Dec 2023 12:34 collapse

Ah I was getting it confused. At one point Steam stored everything in ~/.local/share/steam and symlinked ~/.steam to it. Doesn’t appear to be the case on Ubuntu 22.04, though I used to use Debian and grab the .deb from Valve’s website. My bad! :)

ryannathans@aussie.zone on 03 Dec 2023 03:44 next collapse

I did this and now my games have no icons in lutris, some of my gnome settings got reset and my proton email bridge stopped working

Iapar@feddit.de on 03 Dec 2023 05:29 next collapse

You shouldn’t have done that Dave.

lloram239@feddit.de on 03 Dec 2023 06:56 next collapse

Time to write some bug reports. ~/.cache is supposed to be disposable.

sebsch@discuss.tchncs.de on 03 Dec 2023 09:53 next collapse

So the apps are broken. Cache is meant to be deleted at any time

redd@discuss.tchncs.de on 03 Dec 2023 20:09 collapse

not necessarily during runtime

30p87@feddit.de on 05 Dec 2023 16:56 collapse

But a restart of an app should fix it.

MangoPenguin@lemmy.blahaj.zone on 03 Dec 2023 14:24 next collapse

For some reason devs can’t wrap their head around cache being temporary.

stepanzak@iusearchlinux.fyi on 03 Dec 2023 15:56 collapse

Cannot this be caused by deleting the folder and not just everything inside?

glibg10b@lemmy.ml on 03 Dec 2023 17:57 next collapse

It’s likely. mkdir fails to create a subdirectory such as ~/.cache/mozilla/ if ~/.cache/ doesn’t exist, unless -p is explicitly passed to mkdir

Of course, not everything is a shell script, but I imagine the directory creation functions in many languages work similarly

ryannathans@aussie.zone on 03 Dec 2023 22:28 collapse

The contents were deleted

neonred@lemmy.world on 03 Dec 2023 07:34 next collapse

Because of excessive RAM I symlink ~/.cache to /tmp. Additionally installing zramswap helps for this scenario.

Benefits are faster access, automatc purging between reboots and no wear to the NMVe drive.

Yes, this is a single user scenario.

danielquinn@lemmy.ca on 03 Dec 2023 08:44 next collapse

Isn’t most of what’s in there just filters downloaded from the internet? Python packages, browser cache, etc? Your system confirms you to redownloading everything all the time, no?

Secret300@sh.itjust.works on 03 Dec 2023 15:00 next collapse

Once I get more than 16GB of ram I’ll definitely try that

glibg10b@lemmy.ml on 03 Dec 2023 18:00 next collapse

This seems like a filename conflict waiting to happen. Why not just mount a tmpfs there?

neonred@lemmy.world on 03 Dec 2023 18:24 collapse

Like I said it’s a cheap solution for a single user system. Ofc tmpfs would be better but has to be done for every user again

glibg10b@lemmy.ml on 04 Dec 2023 04:21 collapse

You: It’s a single user system
Also you: Tmpfs would have to be done for every user

And a /tmp/ symlink would have to be created for every user too, so I don’t get your point

Tmpfs is just as easy as making a symlink, but without the filename conflicts between files in ~/.config/ and /tmp/. You just need to add a line to /etc/fstab

tslnox@reddthat.com on 04 Dec 2023 04:47 collapse

/usr/local/sbin/adduser.local

One line in there and you can make it add a new line with appropriate /home/userX/.cache tmpfs line to fstab.

Or, maybe a cleaner way, you might make a init/systemd service that, when booting, would run something like

for each dir in /home do
mount dir/.tmp -type tmpfs
done

I’m not at the computer now and I’m lazy to Google it, so this above is just a pseudo code and probably won’t run.

glibg10b@lemmy.ml on 04 Dec 2023 05:20 collapse

Neat, thanks for sharing

Here’s the above pseudocode in bash:

find /home/ -mindepth 1 -maxdepth 1 -type d -exec mount none {}/.cache/ -t tmpfs -o size=16G \;

for doesn’t work here because it uses spaces to delimit strings, which could cause issues with filenames that contain spaces

You can also create a systemd user service, which is useful if you don’t have root access. The above mount command requires root, but the following doesn’t and is more robust than symlinking to /tmp/:

ln -s $(mktemp -dp /var/tmp/) ~/.config/
library_napper@monyet.cc on 24 Dec 2023 01:36 collapse

Thats not very secure. /tmp/ is usually 777

bizdelnick@lemmy.ml on 03 Dec 2023 08:23 next collapse

You don’t have to clean your ~/.cache every now and then. You have to figure out which program eats so much space there, ensure that it is not misconfigured and file a bugreport.

redd@discuss.tchncs.de on 03 Dec 2023 20:06 collapse

So OP’s headline should be saying instead: Reminder to CHECK your ~/.cache folder every now and then

bizdelnick@lemmy.ml on 03 Dec 2023 23:26 next collapse

Check? Why?

% du -sh ~/.cache
1,6G    /home/bizdelnick/.cache

I don’t remember if I ever cleaned it up. Probably a couple years ago when I moved my old HDD to new PC with freshly installed OS. It does not grow accidentally. Only in some very rare cases. As well as some other dirs under ~ and var. If it is a critical system, set up monitoring of free filesystem space. If not, you will notice if it becomes full (I can’t remember when this happened to me last time, maybe ~15 years ago when some log file started to grow because of endless error messages).

redd@discuss.tchncs.de on 03 Dec 2023 23:36 collapse

Because some users experienced accidential grows like OP had 160 Gbyte. So general advice for linux users can be stated as: Check your ~/.cache every now and then

Critical systems/servers shall better be monitored as you suggest.

bizdelnick@lemmy.ml on 04 Dec 2023 10:19 collapse

Some users experienced accidential growth of /var/log. Some users experienced accidential growth of /var/cache. Some users experienced accidential growth of /var/lib. Some users experienced accidential growth of ~/.xsession-errors. Shall I continue?

Does every user need to begin his day checking all that places? No, he does not. It is waste of time. Such situations are extremely rare. If you are paranoid, check df to see if you have enough free space, and only if it unpredictably shrinked begin to ivestigate which directory has grown.

redd@discuss.tchncs.de on 04 Dec 2023 11:36 collapse

I don’t get your point. Why should somebody do this every day?

As the experience from other users in this thread, it seems not extremely rare to have an overgrown ~/.cache/ folder. So checking it from time to time is a good advice. If we all do this for a time, and create bug tickets for software which is not cleaning up. Then this problem will hopefully go away with future software releases.

bizdelnick@lemmy.ml on 04 Dec 2023 20:56 collapse

Why should somebody do this every day?

Why should somebody do this ever?

As the experience from other users in this thread, it seems not extremely rare to have an overgrown ~/.cache/ folder.

It is the first thread about overgrown ~/.cache directory I see since I use Linux (~16 years or so). But, as I wrote above, this sometimes (rarely) happens with log files and some other directories. Checking each of them is a waste of time, if not automated, checking just one or few of them makes sense only if you are testing some app and looking for files it creates.

cupcakezealot@lemmy.blahaj.zone on 03 Dec 2023 23:44 collapse

just symlink ~/.cache to /dev/null

KSPAtlas@sopuli.xyz on 04 Dec 2023 07:31 next collapse

Cache exists for a reason, that sounds like itd break programs, a safer method is probably having it be a ramdisk

qaz@lemmy.world on 04 Dec 2023 09:49 collapse
Amends1782@lemmy.ca on 04 Dec 2023 21:40 collapse

Lmao some malicious ass advise here

majestic@sh.itjust.works on 03 Dec 2023 09:31 next collapse

No way. If i clean up my .cache directory my precious cached with sccache rust deps would be very upset. >:[

sebsch@discuss.tchncs.de on 03 Dec 2023 09:51 next collapse

Even better: mount ~/.cache as ramfs. It will also speed up some apps significantly.

redd@discuss.tchncs.de on 03 Dec 2023 17:50 collapse

I always felt that there should be some user directory like /tmp/ which will be wiped regularly.

glibg10b@lemmy.ml on 03 Dec 2023 17:58 next collapse

/run/ contains such a directory

Krause@lemmygrad.ml on 04 Dec 2023 21:32 collapse

/tmp and /var/tmp are writable to regular users on most distributions

Lionel@endlesstalk.org on 03 Dec 2023 15:26 next collapse

This is why Linux sucks!

xor@lemmy.blahaj.zone on 03 Dec 2023 16:09 next collapse

That’s nice

PixxlMan@lemmy.world on 03 Dec 2023 16:12 next collapse

Windows famously never generates any garbage files. It’s so reliable all servers run windows. Right?

archy@lemmy.world on 03 Dec 2023 18:12 collapse

Like the kernel itself sucks or a specific distro sucks?

Lionel@endlesstalk.org on 03 Dec 2023 18:44 next collapse

ALL OF IT

zingo@lemmy.ca on 04 Dec 2023 22:02 collapse

Shotgun approach I see.

TheWoozy@lemmy.world on 09 Dec 2023 22:54 collapse

Don’t feed the trolls.

possiblylinux127@lemmy.zip on 03 Dec 2023 15:45 next collapse

Check which folder is the biggest. I am going to go on a lim and say it probably is being caused by file roller

Zangoose@lemmy.world on 03 Dec 2023 16:44 collapse

It’s yay, which took up ~160 GiB. It was storing previous versions of AUR binaries which I guess added up over time. I posted a screenshot of ncdu outputs for a more detailed breakdown in one of the other reply threads

archy@lemmy.world on 03 Dec 2023 18:11 next collapse

yay -Sc(c)

Is probably a better command in this instance

sunred@discuss.tchncs.de on 04 Dec 2023 12:48 collapse

Honestly the reason I’ve put yay/paru’s build directory into ram/tmpfs long ago. It’s almost never worth it keeping all those packages checked out. You also do your ssd a favour by not hammering it with compile workloads.

Shape4985@lemmy.ml on 03 Dec 2023 17:39 next collapse

Bleachbit is good for clearing up some space

OsrsNeedsF2P@lemmy.ml on 03 Dec 2023 22:34 collapse

And deleting emails

zingo@lemmy.ca on 04 Dec 2023 21:59 collapse

Even Hillery knows that one.

Come on!

/s

ArcaneSlime@lemmy.dbzer0.com on 03 Dec 2023 17:40 next collapse

…yeah let me go check that…

13,574 totaling 1.7gb, not too bad. Hey OP how do you get to this view? It looks like we both use nautilus but when I select “properties” on the .cache folder it looks different.

kaesaecracker@leminal.space on 03 Dec 2023 20:50 next collapse

the screenshot does not look like nautilus, maybe xfce?

Zangoose@lemmy.world on 03 Dec 2023 21:43 collapse

I use thunar (with ePapirus-Dark icons which is probably what makes it look like nautilus), I liked nautilus when I used it but thunar has a bit more functionality that I like

ArcaneSlime@lemmy.dbzer0.com on 04 Dec 2023 02:51 collapse

Ah thanks!

redd@discuss.tchncs.de on 03 Dec 2023 17:48 next collapse

Is it safe to clear ~/.cache/mozilla/ while Firefox is running?

Pantherina@feddit.de on 03 Dec 2023 19:13 next collapse

No.

Zangoose@lemmy.world on 03 Dec 2023 21:32 collapse

Maybe not while it’s running, but .cache is intended to be temporary files only so expecting files to permanently be there should be treated as a bug

Pantherina@feddit.de on 03 Dec 2023 19:09 next collapse

Your Distro should normally do that for you.

Advising for this means people will delete random cache and download stuff always.

Are multiple files in there? If yes you could add a script that only deletes files of certain age.

Takios@feddit.de on 04 Dec 2023 22:19 collapse

I’m not aware of any distro that automatically clears a user’s .cache in their home directories. Maybe you’re thinking of /var/cache?

[deleted] on 03 Dec 2023 23:42 next collapse

.

HiddenLayer5@lemmy.ml on 04 Dec 2023 00:01 next collapse

I just map both the user cache and the /tmp directory to a RAM drive. I allocated 4 GB but in practice it never gets even close to that much, and Linux seems to not be reserving the entire 4 GB at boot so I would assume how much RAM is used depends on how much is actually in your cache.

It also defers cache and tempfile related problems to turning it off and on again.

vox@sopuli.xyz on 04 Dec 2023 00:48 next collapse

seems like a bug in one of rhe programs you’re using.
modt software automatically manages it’s cache…
are you using build caching tools such as Mozilla sccache? These tend to create 20gb+ cache directories, especially if used with debug builds

lntl@lemmy.ml on 04 Dec 2023 06:03 next collapse

$ crontab -e

      • */2 * rm -rf /home/lntl/.cache
[deleted] on 04 Dec 2023 06:22 next collapse

.

twei@feddit.de on 04 Dec 2023 11:22 collapse

I guess you could also Mount a tmpfs to that directory

therealjcdenton@lemmy.zip on 04 Dec 2023 10:40 next collapse

NEVER

<img alt="" src="https://lemmy.zip/pictrs/image/d48cb113-84c0-44e1-ae7d-7bb23f172fcf.webp">

sunred@discuss.tchncs.de on 04 Dec 2023 12:31 collapse

du -sh ~/.cache/* | sort -h

Atemu@lemmy.ml on 05 Dec 2023 14:29 collapse

ncdu ~/.cache/