I am new to Raspberry Pi and Raspbian. Just curious, can I delete the ~/.cache folder?

What is its purpose?

Can I automate the deletion process for this folder? What's the command/scripts that I can use to auto-delete it once a week?

  • 1
    Welcome to the Raspberry Pi SE site. Please take a few moments to take "the tour" to familiarize yourself with how things work here. Also please read these guidelines on asking good questions. A quick search will often yield useful answers to questions, or guide you in asking a "better question". – Seamus Dec 25 '18 at 19:03
  • 1
    this is not an RPI question ..... it is a Linux question .... please use google search linux .cache to get your answer – jsotola Dec 25 '18 at 19:42

You can learn a lot more, and with a smaller investment in time, by simply "Googling" for information on what the cache is, and how it's used in modern *nix systems. For example, the following search term in Google yields numerous results that may help you: linux purpose of .cache.

With that out of the way, I'd answer your questions as follows:

  1. What is the purpose of ~/.cache?: The purpose of the ~/.cache is to provide a common area in which applications can store information that may be needed in the future. By storing this information in the cache, the application may be able to do its job more quickly and efficiently. This may save you time, and make more effective use of your RPi's resources.

  2. Can I delete the folder? If you have the requisite privileges, then, "Yes, you can delete the folder." Perhaps a better question is, "Should I delete the folder?" For me, the answer is generally "No". Why? Because I don't feel the need to delete things simply to free resources that I may or may not need. If I had reason to believe or suspect that an application was misusing the cache, then I certainly would delete it (and probably delete the application as well!).

3.a. Can I automate the deletion process for this folder? Yes, you can automate it in one or more ways.

3.b. What's the command/scripts that I can use to auto-delete it once a week? I would use cron for that job. To employ cron, you only need to add a line to your crontab file. You can learn more about using cron through a Google search, and by typing man cron and man crontab at the command line. Try this, and if you have specific questions, let us know.

  • Well reasoned and rounded answer but I would caution that deleting the cache folder from cron at intervals might run into problems with cache files still being accessed by their creators. I'd mention the @boot directive for cron in "3b" and possibly add a "3c" suggesting reading up on ways to add a custom script to the shutdown process to tidy up the .cache folder. – Roger Jones Dec 29 '18 at 20:01
  1. Install bleachbit
  2. Set up a cron job tu run bleachbit --clean system.cache at whatever time you wish.

Description: delete unnecessary files from the system BleachBit deletes unnecessary files to free valuable disk space, maintain privacy, and remove junk. It removes cache, Internet history, temporary files, cookies, and broken shortcuts.

It handles cleaning of Adobe Reader, Bash, Beagle, Epiphany, Firefox, Flash, GIMP, Google Earth, Java, KDE, OpenOffice.org, Opera, RealPlayer, rpmbuild, Second Life Viewer, VIM, XChat, and more.

Beyond simply erasing junk files, BleachBit wipes free disk space (to hide previously deleted files for privacy and to improve compression of images), vacuums Firefox databases (to improve performance without deleting data), and securely shreds arbitrary files. Homepage: https://www.bleachbit.org/

  • Interesting application... how long have you used it ? Do you find it improves things much? – Seamus Dec 29 '18 at 18:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.