Skip to content

Instantly share code, notes, and snippets.

@ftpmorph
Last active March 12, 2021 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftpmorph/d0bd6fc824ef0a8f86def233e91e3b66 to your computer and use it in GitHub Desktop.
Save ftpmorph/d0bd6fc824ef0a8f86def233e91e3b66 to your computer and use it in GitHub Desktop.
mastodon user's crontab to keep cache from piling up - login to mastodon acct and run crontab -e to add this
#!/bin/bash
PATH=/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/bin:/usr/local/bin:/usr/bin:/bin
# Output of commands will be written to log files specified in home folder of mastodon user
# This allows for easy debugging, but once you know it works you can remove the part starting at >> to disable logging
# Conversely if you want more output in the log you can add "--verbose" to the command
# Tried and tested successfully with mastodon v3.3.0 and the v3.3.0+glitch fork.
# Clears cached media from other instances that's over a week old by default. You can add "--days 3" for example to clear out media quicker.
@daily cd /home/mastodon/live && RAILS_ENV=production bin/tootctl media remove >> /home/mastodon/cachewipecronjob.log 2>&1
# Clears the link, photo, video etc previews generated in feeds. Default value for removal is over 180 days old.
# Official docs note previews won't be refetched if the links were posted less than two weeks ago so make 14 days the minimum if you change this.
@weekly cd /home/mastodon/live && RAILS_ENV=production bin/tootctl preview_cards remove >> /home/mastodon/previewwipecronjob.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment