Delete Plex TV Shows and Movies After Watching

Delete Plex TV Shows and Movies After Watching
Photo by No Revisions / Unsplash

Plex-Cleaner is a Python script that can clean up your Plex directory by deleting movies and TV shows after you've watched them. This will stop your disk from filling up with lots of old media files over time. You can run this script on your server (or Raspberry Pi, or wherever you run Plex Media Server.)

I like to put things in the /opt directory on my servers.

  • Run git clone /opt

  • Run python3 --dump Cleaner.conf to create a new configuration file

  • Configure an authentication token in Cleaner.conf, under the "Token" key.

  • Call python3 to test it out.

The script will run in test mode and won't delete anything if your Cleaner.conf contains "test": true, or if you call python3 --test.

  • After everything looks good in the logs, set "test": false in Cleaner.conf.

You'll probably want to run this script regularly as a cron job. Run crontab -e to edit your crontab, then add the following line to run the script every day at 4am:

0 4 * * * /usr/bin/python3 /opt/Plex-Cleaner/

I always like to set up monitoring for any scheduled scripts so that I get a notification if when they stop working. is my favorite monitoring tool and they have a generous free tier. (No affiliation, they're just an awesome service.)

To set up monitoring with, you can call the script from my fork. This script will ping on success or failure. will also send you a notification if it doesn't receive any ping at the expected time (e.g. if your server has been turned off.)

  • Sign up for a free account.
  • Create a new check. Choose the "Cron" schedule and enter your cron expression, e.g. 0 4 * * *.
  • Make sure you also set the correct Time Zone in the options.
  • Save the check ID to a healthchecksio_id file in the Plex-Cleaner directory
  • Set the log file option in Cleaner.conf so that it writes logs to a file:
"LogFile": "/opt/Plex-Cleaner/plexcleaner.log",
  • Set up this cron job entry (instead of the one above):
0 4 * * * /opt/Plex-Cleaner/

Now you'll get an email alert whenever something goes wrong:

  • The script exits with an error
  • The plexcleaner.log log file contains any ERROR entries
  • The script doesn't run at all

Read more