Marian Paździoch
Marian Paździoch

Reputation: 9113

Reduce gradle daemon disk space (it takes up to 50GB)

I'm developing in Android Studio with gradle.

My .gradle/daemon/ takes up to 50GB of space.

It consist of about 50 files between 1MB and 3GB in size.

How can I reduce size of that folder? How to clean it up safely?

enter image description here

Upvotes: 7

Views: 8359

Answers (2)

Zac
Zac

Reputation: 61

On Windows, on the other hand, you may do something like this:

Create in your gradle folder a batch script (text file), with a filename 'clean-logs.bat'.

Inside, you can put just one line with the command as follows:

del C:\Users\username\.gradle\daemon\*\*.log

'username' should be replaced with the right one for you and basically complete path should point correctly to where your gradle instalation is placed and it's logs files are generated.

You can test your simple script manually by double-clicking on it, or running it from Command prompt - it should erase all logs in '.gradle' folder - without reporting an error, if there are some existing at the moment.

Now you can schedule this task - for automatic repeated clean-ups, as follows:

  1. search for app Task Scheduler
  2. Create Basic Task & name it something like 'Gradle Logs Cleaner'
  3. choose wanted schedule - lets say weekly, every Monday at some desired time
  4. action - Start a program - and point it to previously created 'clean-logs.bat'
  5. you should also put your gradle folder path in 'Start in', just for the safety reasons, as script is dealing with deleting certain files

That should basically do it.

Upvotes: 2

Zac
Zac

Reputation: 61

You could for example, regularly delete *.out.log files in your home directory .gradle folder, by following command:

find ~/.gradle -name '*.out.log' -exec rm {} \;

You can put it with crontab -e to be repeated periodically at some appropriate time.

In this example, 'cleaning' would be executed on 11am every Monday:

$ crontab -l

0 11 * * 1 /usr/bin/find ~/.gradle -name '*.out.log' -exec rm {} \;

This will work on any linux or mac os x.

Upvotes: 3

Related Questions