Skip to content

Commit

Permalink
feat: add a section on periodic cleanup tasks (#816)
Browse files Browse the repository at this point in the history
* feat: add a section on periodic cleanup tasks

I asked in Discord today about which `tootctl` tasks are good to run on a regular basis (as there are a lot of cleanup jobs). It seems that `media remove` and `preview_cards remove` are the standard ones that you want to run on a regular basis (e.g. with cron). So I added this to the docs in its own section, under "Things to do after installing Mastodon."

* fix: fix typo
  • Loading branch information
nolanlawson committed Sep 28, 2020
1 parent e47834d commit 4617ea9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions content/en/admin/setup.md
Expand Up @@ -44,3 +44,19 @@ After logging in, navigate to the **Site settings** page. While there are no tec

After you fill these in, simply hit “Save changes”.

## Running periodic cleanup tasks {#cleanup}

Mastodon generates some temporary files that are worth cleaning up after a certain amount of time (e.g. to save money on hosting). In general, you want to set up `cron` jobs (or another mechanism) to run these periodic cleanup tasks.

Typically you want to run [`tootctl media remove`](https://docs.joinmastodon.org/admin/tootctl/#media) and [`tootctl preview_cards remove`](https://docs.joinmastodon.org/admin/tootctl/#preview_cards) periodically. These will clean up remote media (e.g. images, videos, audio) and preview cards (e.g. preview images for links) after a certain number of days. (Check the docs for those commands if you want to tweak how old something has to be before it's cleaned up.)

First, run `crontab -e` to edit the cronfile for the `mastodon` user. (If you get a prompt asking which editor to use, choose your favorite editor.)

Next, add something like the following to the bottom of the file:

@weekly RAILS_ENV=production /home/mastodon/live/bin/tootctl media remove
@weekly RAILS_ENV=production /home/mastodon/live/bin/tootctl preview_cards remove

This will run these two commands on a weekly basis.

Finally, save the file. You can use `crontab -l` to verify the configuration.

0 comments on commit 4617ea9

Please sign in to comment.