Deleting Cache Files

Hi,

Is it safe to delete the files from the below directory of sonarqube machine -

**2.4G /root/.sonar/cache/

Will it affect the sonarqube application if we delete this cache directory ?

Thanks!

Hi,

Welcome to the community!

I assume you’re seeing this on the build agent? Deleting it may have an impact on speed, but not on accuracy or the ability to execute successfully.

 
HTH,
Ann

Hi Ann,

I’m viewing this from the sonarqube server which is running on CentOS 7 and this directory (under /root) is taking up 2.4 GB of storage.

So deleting this directory or some files of this directory will impact on speed of sonarqube application ?

Thanks!

Ehm… hmm…

I’m looking at my own .sonar directory now. (Hey, look! I have a .sonar directory!)

The SonarQube bundle includes a jar file for each analyzer. It looks like each subdir here is an expansion of each analyzer & its dependency jars… For each analyzer… For each version(?).

I guess there should probably be some automatic cleanup here, probably during upgrade. (Be sure I’ll ping the team about that.)

You’re probably good to clean this out, but I would:

  • shut down SonarQube
  • clean up
  • restart (and expect some of the subdirs to be repopulated)

 
HTH,
Ann

Hi,

it seems you’re running the Sonar scan on the same machine Sonarqube server runs on !?

Normally the scanner runs within a CI server as Jenkins … etc. or on a dedicated build server -
separated from the Sonarqube server.

.sonar/cache is the directory (default user home/.sonar/cache) created by Sonar scanner initially downloading all plugins from the Sonarqube server, has to be done once after every Sonarqube update.
Even plugins not needed for scanning are downloaded, see

Deleting the contents will not help, as the subsequent scan will need to download all the plugins again,
so you should leave it as is.
Better fix your setup, the Sonarqube server should run no other applications, so all ressources
are available for Sonarqube alone.

@ganncamp i didn’t notice any automatic cleanup of /.sonar/cache by the Sonar scanner during update, has to be done manually

Gilbert

1 Like

Thanks for your insight @anon67236913!

In fact, when I do my testing I run both the server and the analysis on my localhost because… that’s what I have. That explains why I have a .sonar directory. This isn’t from running the server; it’s from running analysis!

So my initial answer stands: you can clean it out, but it will impact analysis speed because the files will have to be redownloaded & reexpanded.

And yes, what Gilbert said: in production you should run the SonarQube server on a box than hosts your build agents.

 
Thx again Gilbert,
Ann

Edit: Phew! I must be tired :sweat_smile: