Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to automatically remove cached media files older that 7 days from your Mastodon instance
This is how to automatically delete cached image previews from your Mastodon instance if they are older than 7 days.
Log in as your "mastodon" User or log in as root and then change to the "mastodon" user, who runs Mastodon:
# su - mastodon
Open crontab:
$ crontab -e
... and add these lines to your crontab:
SHELL=/bin/bash
PATH=/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/bin:/usr/local/bin:/usr/bin:/bin
###
### Mastodon cronjobs for media cache purging
###
RAILS_ENV=production
@daily cd /home/mastodon/live && bin/tootctl media remove
Edit the editor. The new Cron Job will be accepted.
This script assumes that your Mastodon Sourcecode lives in /home/mastodon/live (as suggested by the official setup guide).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.