Running Scheduled Tasks

Just as with any server, a Plex server should have periodic maintenance tasks run to keep the server running at optimal performance.

There are different tasks that can be run, as well as different ways to run them. The next few sections discuss the tasks you can run and how you can schedule them to run at the best time.

Running Scheduled Tasks for Plex Maintenance

Table of contents

Plex scheduled tasks
Enabling the scheduled tasks
Running the tasks on a different schedule

Plex scheduled tasks

Plex Media Server includes many scheduled tasks that can be run periodically to ensure your server is running as fast as possible.

The tasks can perform many basic maintenance functions, such as backing up and optimizing the database, refreshing metadata, and cleaning up old files.

The list of these tasks is as follows:

Backup database every three days

Every 72 hours, a backup of the SQL database file will be generated (provided it is not already corrupted). This database houses essential information such as media viewstate. Having backups serves as a safeguard against potential corruption, which may occur in rare instances like sudden machine shutdowns.

A maximum of three backup copies will be maintained in a rotational system.

This task will only back up the database. This won’t provide a full backup of your Plex server. You can refer to How to Backup Plex Data for information on backing up all your Plex data.

Optimize database every week

This activity will optimize the Plex database to ensure it is running at its best, particularly following numerous additions or deletions that may otherwise cause a slowdown.

Remove old bundles every week

Important details such as metadata, artwork (posters, banners, art, etc.), and similar data are bundled together. When you remove something from a library, these bundles stick around for a bit by default. This helps in case you want to bring back the item. This task is all about deleting the bundle packages tied to things you've taken out of your collection.

Remove old cache files every week

When Plex Media Server processes pictures, like resizing them, it saves a faster-to-access copy of the changed file. This task cleans up cache files that were created more than a month ago.

Refresh local metadata every three days

If you put in a new subtitle or cover art file, the local media agent will notice and put it in the library. This usually happens right away if the server sees a change in the folder time. But, it takes a second or two when you pick something in your library before it shows up. So, doing it at night makes sure it's fast during the day.

This task does not download new metadata for your media items.

Update all libraries during maintenance

This task will run a scan on your libraries to find new content. Any metadata for existing content will not be refreshed. This task is disabled by default.

Upgrade media analysis during maintenance

Plex will check every file carefully to make sure it plays correctly on different devices and apps. Sometimes, Plex will fix issues with how files are checked or get additional information. Like local metadata, Plex figures this out when needed, but it might take a bit when you choose something. This task makes sure the Plex checks are always up to date.

Refresh metadata periodically

Throughout the month, the server will update the information about music artists and TV shows in your library. This ensures that your artists have accurate tour date details (if you've turned on that feature) and Plex Pass users with music libraries will automatically receive new lyrics from LyricFind (if enabled), for example.

Running this task will only refresh metadata for music and TV shows

Perform extensive media analysis during maintenance

This conducts a detailed analysis of the bitrate for every file in your library, aiding in bandwidth control.

Fetch missing location names for items in photo section

If you've turned on the Save location names preference for a photo library, this allows the server to retrieve names for locations using the embedded geo data in the photos.

Enabling the scheduled tasks

To enable the tasks mentioned above you can use the following steps:

  1. Log into your Plex server as an administrator, and then click the Settings - the wrench - link in the upper-right corner of the Plex server page.
    Plex Settings Icon.
    The 'Plex Settings' icon
  2. Scroll down the menu on the left, and then click the Scheduled Tasks option in the Settings section.
    Plex Scheduled Tasks Option.
    The Plex 'Scheduled Tasks' option
  3. From the list of scheduled tasks, uncheck to disable a scheduled task, and check to enable a task. Click the Save button to apply your changes.
    Plex Scheduled Tasks.
    The Plex 'Scheduled Tasks' selection

You can select the start and stop times for when the scheduled tasks can run using the two options above the list of scheduled tasks.

The database backup directory is not displayed by default. You can click the Hide Advanced button to show that option, which will allow you to specify the backup directory for the database.

Running the tasks on a different schedule

When using the built-in scheduled tasks options in Plex, you will notice that some of the tasks will only run at specific intervals. For example, the database backup task will only run every three days, while the old bundles and cache files will be removed once a week.

You can run these tasks on your own schedule by utilizing the Plex API to run the commands manually.

The easiest way of scheduling these commands is to use the curl command to call the following API commands:

For example, to clean old bundles using the curl command you can use the following:

curl -X POST http://{plex_server_ip_address}:32400/butler/CleanOldBundles?X-Plex-Token={plex_token}

You will need to use the Plex authentication token when sending the request.

By running the tasks on your schedule, you can ensure the tasks don't interfere with using your server, and your Plex server will be running at optimal performance.

Subscribe
Display