Skip to content

Instantly share code, notes, and snippets.

@questionlp
Last active June 16, 2025 19:21
Show Gist options
  • Save questionlp/6d1be7988528c3005c4daf9715318c4b to your computer and use it in GitHub Desktop.
Save questionlp/6d1be7988528c3005c4daf9715318c4b to your computer and use it in GitHub Desktop.
Mastodon Cache Cleanup Scripts

Mastodon Media Attachment Cleanup Scripts

The following bash scripts can be used to clean up the Mastodon caches to recover some space.

#!/bin/bash
cd ${HOME}/live
PATH=${HOME}/bin:${HOME}/.local/bin:${HOME}/.rbenv/plugins/ruby-build/bin:${HOME}/.rbenv/shims:${HOME}/.rbenv/
bin:/usr/bin:/bin
RAILS_ENV=production bin/tootctl media remove --days=3 > log/media_remove.log 2>&1
#!/bin/bash
cd ${HOME}/live
PATH=${HOME}/bin:${HOME}/.local/bin:${HOME}/.rbenv/plugins/ruby-build/bin:${HOME}/.rbenv/shims:${HOME}/.rbenv/
bin:/usr/bin:/bin
RAILS_ENV=production bin/tootctl media remove-orphans > log/media_remove-orphans.log 2>&1
#!/bin/bash
cd ${HOME}/live
PATH=${HOME}/bin:${HOME}/.local/bin:${HOME}/.rbenv/plugins/ruby-build/bin:${HOME}/.rbenv/shims:${HOME}/.rbenv/
bin:/usr/bin:/bin
RAILS_ENV=production bin/tootctl preview-cards remove --days=7 > log/preview-cards_remove.log 2>&1
00 3 * * * ~/scripts/clean_media.sh
15 3 1 * * ~/scripts/clean_preview_cards.sh
30 3 * * 2 ~/scripts/clean_orphans.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment