Last active
January 14, 2026 05:36
-
-
Save njregenwether/42e8751c751f04e41bb23f23ec416d0d to your computer and use it in GitHub Desktop.
Manually Scan Plex Library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ########################################################################################################################## | |
| # This will update plex libraries manually from the command line. # | |
| # This will work on centos 7 but I can't make any guarantees about other OSes or platforms. # | |
| # If you're running plex on mac os x or windows, get a real OS. # | |
| # # | |
| # The exports below are important because if you don't have all of them set, you will get no result when you go to list # | |
| # ./Plex\ Media\ Scanner --list # | |
| # This will show you all of your libraries and their numbers. # | |
| # # | |
| # The idea is that you should schedule this in a cron job. Here is my example of how I scheduled my script. # | |
| # # | |
| # */5 * * * * ManuallyScanPlexLibrary.sh >> statuslog 2>> errorlog # | |
| ########################################################################################################################## | |
| ## These exports are important. Don't forget them. | |
| export LD_LIBRARY_PATH="/usr/lib/plexmediaserver" | |
| LANG="en_US.UTF-8" | |
| export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" | |
| export PLEX_MEDIA_SERVER_TMPDIR="/tmp" | |
| export PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" | |
| export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/plexmediaserver/Library/Application Support" | |
| ## Plex library number, my example is 2, yours will be different ## | |
| ## Can get this by running /usr/bin/plexmediaserver/Plex\ Media\ Scanner --list ## | |
| PLEXLIBNUM="2" | |
| ## This will scan for new media, then perform a refresh which will | |
| ## update all the metadata associated with the media. | |
| /usr/lib/plexmediaserver/Plex\ Media\ Scanner -s -r -c "${PLEXLIBNUM}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not work anymore (besides -s being deprecated) they renamed the table columns:
soci_error: sqlite3_statement_backend::prepare: no such column: library_sections.content_changed_atThe tool crashes with this on a
-s -c 1and even on a simple--list.Server version:
v1.30.1.6562-915986d62Edit:
What worked for me, is to login to the web UI and create a curl request for refreshing (the chrome devtools allow you to create a curl request in the network tab to replay any request made) , which is basically a request to:
https://localhost:32400/library/sections/1/refreshwith all the parameters used in the web UI (I hope myX-Plex-Tokendoes not expire... though)