Mastodon Cache Clearing Guide

Clearing Mastodon’s caches

Mastodon caches files from other servers, and those cached files have to be cleared occasionally, or the tilde’s disk will fill up, causing the tilde to die until it has free space.

Clearing the caches

sudo su -l -c "source /home/mastodon/.bashrc&&cd live&&RAILS_ENV=production bin/tootctl media remove --days 0&&RAILS_ENV=production bin/tootctl media remove --days 0 --prune-profiles" mastodon

This is the only safe way to clear the cache. If you delete cached files any other way, Mastodon WILL break. If you get an error, wait for that command to exit, then reply with the error message. It takes about 12-24 hours for Mastodon to fill the server, so manually clearing the cache every 6 hours is a good idea.

Here’s an example of what should happen when clearing mastodon’s cache

h@tilde:~$ sudo su -l
[sudo] password for h:
root@tilde:~# df -h /
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv   77G   71G  3.2G  96% /
root@tilde:~# su - mastodon
mastodon@tilde:~$ cd live
mastodon@tilde:~/live$ RAILS_ENV=production bin/tootctl media remove --days 0
15453/15453 |================================================================================================| Time: 00:02:38
Removed 15454 media attachments (approx. 13.2 GB)
mastodon@tilde:~/live$ RAILS_ENV=production bin/tootctl media remove --days 0 --prune-profiles
39081/39089 |=============================================================================================== |  ETA: ??:??:??
Visited 39086 accounts and removed profile media totaling 3.25 GB

What if you run a cron command?

Clearing mastodon’s cache uses a lot of RAM iirc, so it’d be risky to make it run automatically

Just made mastodon some aliases.

sudo su - mastodon
cd live
1 Like

@9pfs thoughts?