I dont normally like these kinds of utilities… so I figured I would make one.
Its up on gitlab:
Its still early days.
Every action prompts the user first, with default response being negative.
I am still compiling all of the ‘cleaning actions’ it should take.
It should loop through any number of AUR helpers installed.
(includes: pacaur, pamac, paru, pikaur, trizen, yay)
SNAP/Flatpak cleanings are also included to the best of my knowledge, but I dont use either.
(and these will only be presented if snap is running or flatpak is installed)
As always feedback is welcome.
Let me know if its doing something dumb or if there is something you think should be included.
18 find ~/.cache/thumbnails -mindepth 1 -type f -mtime +14 ;
I can’t bash script my way out of a wet paper bag, but is that line missing a
I’m just wondering why the thumbnail cache is cleaned separately using the mtime when immediately afterwards the home cache (which contains the thumbnail directories) is cleaned using the atime. Wouldn’t it be better to use atime on the thumbnails as well? If using mtime, thumbnails which are accessed on a regular (such as daily) basis will still be deleted every 2 weeks, requiring the writing of new, identical thumbnails to the disk.
Also, it might be wise to omit the Firefox cache folder from cleaning as Firefox manages its own cache. This is what I’ve been using for quite a few years in my own cleanup script which runs every startup:
find ~/.cache/ -depth -type f -not -path "*mozilla/firefox*" -atime +45 -delete
Thats what I get for doing a last minute check, but not checking what I did during said check.
I agree I should probably use access for both.
The reasoning for keeping them separate was to … well, keep it separate … so that one wishing to only delete the thumbnails (which on its own can grow rather large over time) without necessarily wanting to purge the whole cache of anything ‘old’.
I think I might adopt your attitude towards the firefox cache … possibly adding others to the omission (chromium, thunderbird).
Nice idea. I like the separation of jobs.
My cleaner does:
pamac clean --build-files
flatpak uninstall --unused
journalctl --flush --rotate
So I’m interested to mix and match a bit.
I see where you’re coming from. Maybe just changing the menu option to “Clean thumbnail cache of ALL files older than 2 weeks (y/N)?” would prevent any confusion.
Overall, the script is a very good idea. It has always irritated me ever since I started using GNU/Linux in 2005 that there is no automated function to clean old, unused files from the cache.
I changed and added some things, due in part to the comments here.
Of note: Incorporated fixes from above, new prompt for orphans, and a check/warning of pacnews.
Update again. Now with
-h (help) and
-a (automatic ‘yes’ mode) options.
Original mode of ‘just run and get prompted’ still intact.
And a note on the name…
Yes its Ma
njaro+clean but as usual it has multiple interpretations…
Its also one letter away from a certain common cleaning product, and phonetically similar to certain regal figure of yesteryear.
Cheers until next time.
Put in a check to disallow running as root, pacnew warning now only fires if you have them, and added a snazzy icon.
ToDo: Find a new extra-permissive (joke?) license.
Clean thumbnail cache of files not accessed for 2 weeks (y/N)?
Clean HOME cache of files not accessed for 2 weeks (y/N)?
Clean journal of all logs older than 2 weeks (y/N)?
Vacuuming done, freed 0B of archived journals from /var/log/journal.
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Vacuuming done, freed 0B of archived journals from /var/log/journal/d24beb85f3334ebb96b273459eede537.
Clean old and unused Flatpak REFs (y/N)?
Nothing unused to uninstall
Fehler: Error opening directory '/home/weingeist/.var/app': Datei oder Verzeichnis nicht gefunden
If you do not use flatpak and answer yes, the script will be cancelled.
A wonderful script, of course. Thank you for it
Thanks. That comes from
flatpak uninstall --delete-data.
This prompt only shows up if you have
flatpak installed … but since flatpak fails out trying to clean if it cant find that folder … I will make this part only fire if the directory exists.
(the whole prompt only fires if flatpak is installed … but that doesnt mean you have been using it)
Now with support for
Better prompt for automatic mode (gives warning, resets
sudo, asks for password verify)
Even less prompting now (package cache checked before asking, ex: no prompt for uninstalled cache if there are none)
Also added some more output like “Done” and “Skipped”.
And one more thing most will not notice
(for the paranoid … its a check for ancient flash directories)
The heaviest functions still do not check prior to prompting.
I consider the load too high to do automatically (these all rely on traversing the filesystem to some degree). But this does all add up to a rather slim output if the system is clean;
Clean thumbnail cache of files not accessed for 2 weeks (y/N)? y
Clean HOME cache of files not accessed for 2 weeks (y/N)? y
Clean AUR Helper cache of all build files (y/N)? n
Whole new post because lots of updates.
All major browser caches are skipped (vivaldi, brave, chromium, chrome, ff, thunderbird)
Many internals to make it a bit faster and such.
The big one is a now -easily- configurable “junk directories” that the user can augment, at the top of the script. It replaces the previous check for ancient flash folders, which now become the default population of the junk folders.
PS. Settled on beerware license for now. Not my most favorite, but one I had not used yet.
Script stops with:
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
when cleaning $HOME cache
Oo fun … we must have a funny file name in there?
Maybe you can check with a stripped version to print:
find ~/.cache -mindepth 1 -type d ! \( -readable -executable \) -prune -o ! -path */yay/* ! -path */vivaldi/* ! -path */trizen/* ! -path */pip/* ! -path */pikaur/* ! -path */paru/* ! -path */pamac/* ! -path */pacaur/* ! -path */thunderbird/* ! -path */manjaro-tools/* ! -path */mozilla/* ! -path */google-chrome/* ! -path */chromium/* ! -path */chroots/* ! -path */BraveSoftware/* -type f -atime +14 -print
Or if the output is too large you can send it to a file:
find ~/.cache -mindepth 1 -type d ! \( -readable -executable \) -prune -o ! -path */yay/* ! -path */vivaldi/* ! -path */trizen/* ! -path */pip/* ! -path */pikaur/* ! -path */paru/* ! -path */pamac/* ! -path */pacaur/* ! -path */thunderbird/* ! -path */manjaro-tools/* ! -path */mozilla/* ! -path */google-chrome/* ! -path */chromium/* ! -path */chroots/* ! -path */BraveSoftware/* -type f -atime +14 -print > myoldcachefiles.txt
And view it, ex;
( I have of course double checked and it runs here. )
While I havent heard back from @wes33 yet…
I did make some changes to the script.
Please try the latest version and let me know how it works for you.
I like to actually keep them super permissive.
Otherwise I would make sure to rant all my personal politics etc.
Though … I have been tempted by the “Be Gay Do Crimes” License, and this one:
(which stipulates you must commit no less than 3 US criminal offenses )
Then I’m glad I like doing this kind of thing manually.
Because I’m too boring for that even if I did live in, or ever was even close to the US.
Violating the terms of the license should count for at least one …
I jest about using them of course though.
As I said - I like them to be permissive so that people can be/feel free with it.
(But that certainly doesnt mean I cant have fun with it … I still think I like the cat supremacy license best … the final line is something like “all others are given the above rights, albeit grudgingly”)
The new version fixes the problem
Which was a file whose path included the string:
Love’s Crushing Diamond
thanks for the quick fix; script is a great idea
Glad to hear it, and thanks for helping make an improvement
Firefox cache clean shows ‘y/n’.
I’d hope for ‘y/N’ for a sane default.