hello, warganet!

How to Eventually Free Up Your Disk Space

Cover Image for How to Eventually Free Up Your Disk Space
clement
clement

hola.

So this morning I've got one problem with my disk space. I have a SSD with 240gb storage, and since I have 2 instances of Windows Subsystem for Linux (WSL) with a total of 45-ish gb - 30gb for instance A, and 15gb for instance B - that really ruined my storage πŸ’€πŸ˜­

So, after purging the WSL first instance, my free storage is available around 60-ish gb. But I need more threshold for my storage 😭

After seeing my storage over WinDirStat, Spotify took 10gigs from my storage. I can delete the cache from Spotify’s setting menu, but I need a more convenient way to delete this Spotify cache.

First we need to see the path of the Spotify cache. I got C:\Users\cleme\AppData\Local\Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0 path, but I want find the more deeper path, since this directory not only saving cache, but also saving application data.

After digging deeper, I’ve found the 10gigs cache is in /LocalCache/Spotify/Data

From here, we can get the full path of this directory, and we need to set up a task scheduler for removing this cache directory. Since I installed a WSL instance, I think I might set a crontab for deleting this directory. So, we’ll write a bash script for deleting all of the cache in this directory.

First, we need to convert the Windows path to the WSL path.

Windows: C:\Users\cleme\AppData\Local\Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0\LocalCache\Spotify\Data

WSL: /mnt/c/Users/cleme/AppData/Local/Packages/SpotifyAB.SpotifyMusic_zpdnekdrzrea0/LocalCache/Spotify/Data/

The final script will be

#!/bin/bash cd /mnt/c/Users/cleme/AppData/Local/Packages/SpotifyAB.SpotifyMusic_zpdnekdrzrea0/LocalCache/Spotify/ && rm -rf /Data/*

Save it as a .sh file, then we can test the script. But first, we need to make this script executable. To do this, we can use the chmod command like chmod u+x clean-cache.sh.

After that, we should test the script. And look, it's werking πŸ†–πŸ†Ž!

Then, we’ll need to define the cron schedule expression. I need to delete this cache each month at 1st day, 1:23pm, so the cron expression will be 23 13 1 * * ./clean-cache.sh. I will test it first using * * * * * to check is the cron is working well or not πŸ‘

The cron is working, then we need to set the cron expression to 23 13 1 * * to expect the desired condition.

That is all of how to eventually free up your disk space. You can use this technique by using Task Scheduler in Windows, or cron in MacOS. Thank you! πŸ˜­πŸ™πŸ‘‹