Plex Media Scanner hangs when called via command line

From the server logs and the content updating as expected in the Plex UI, a scan initiated from the UI works as expected. However, when I try to initiate a scan via the command line it just hangs. I’m able to pass the -h switch and get the help output, but other than that every other command including a basic list command hangs indefinitely. The commands I run to simulate the issue are:

sudo -u plex /bin/bash export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
$ /usr/lib/plexmediaserver/Plex\ Media\ Scanner --list

I’m running Ubuntu 17.04. Please let me know if there’s something I’m missing or if there’s any other information you need.

Thanks,
Brad

Don’t forget PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR :slight_smile:

That did it! Thanks ChuckPA! I was beating my head against the wall on this one. Looks like Plex’s documentation is way out-dated on this topic unless there’s a newer post I’m missing.

https://support.plex.tv/hc/en-us/articles/201242707-Plex-Media-Scanner-via-Command-Line

Hope to return the favor someday.

Best regards,
Brad

So what is it in the end? An extra
$ export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR = /path/to/folder

Sorry, no linux expert but to call stuff from the cli seems interesting.

if you are using the default configuration:

export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/Plex Media Server/Application Support"

The manual scanner is only needed if you want to automate scan times which the Settings cannot handle OR you have external events happening and want to trigger a full scan.

Thanks that’s how I thought it will work. Well sometimes I throw files at the library folder and I want it to directly appear. There I would want to scan manually, for example.

Have you enabled “Update my library automatically when changes detected” ? Automatic detection pauses ~15 seconds to make sure a change is stable before starting the actual scan.

Also, allowing “partial scan” saves a lot of time.

I did, somehow this is not always working as I thought, especially music I have to manually update.

@bgwallace said:
That did it! Thanks ChuckPA! I was beating my head against the wall on this one. Looks like Plex’s documentation is way out-dated on this topic unless there’s a newer post I’m missing.

https://support.plex.tv/hc/en-us/articles/201242707-Plex-Media-Scanner-via-Command-Line

Hope to return the favor someday.

Best regards,
Brad

The documentation is not up to date

There are new elements that need to be defined. For example these environment variables

EAE_ROOT
FFMPEG_EXTERNAL_LIBS
X_PLEX_TOKEN

Best to schedule a manual scan and then look at the log and see the syntax of how the paths are defined for the first two.
The token - you can see in the Preferences.xml file as the string in PlexOnlineToken

The log file to look at is Plex Media Server.log and look for Job running and see the scanner job being logged as being started. We log how we set the first 2 environment variables for the job

There have been changes that affect scanning - for example photos libraries are now handled directly by the Plex Media Server. So the current position is changing with new developments and the documentation is no longer valid

Try with these extra environment variables and see if that helps

Thanks sa2000. Adding PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR resolved the issue I was facing. Can you please help me understand the purpose of adding the additional environmental variables?

@bgwallace said:
Thanks sa2000. Adding PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR resolved the issue I was facing. Can you please help me understand the purpose of adding the additional environmental variables?

One is to specify where the DTS audio encoding temp files would go (for EasyAudioEncoder) and the other points to the codecs directory

We need to run the transcoder on some files when scanning

Example - scanning a tv show library, ends up running the transcoder in-line and it needs to know where the codecs are

This is an example from my scanner log for a test library with an avi

Aug 07, 2017 13:08:00.879 [22916] DEBUG - [MI] Opening input file: C:\Users\Public\Plex-Tests\TV-Shows Wilson\Curb Your Enthusiasm\Season 2\Curb Your Enthusiasm - S02E06 - The Acupuncturist.avi
Aug 07, 2017 13:08:00.879 [22916] DEBUG - [FFMPEG] - Setting default whitelist 'file,crypto'
Aug 07, 2017 13:08:00.880 [22916] DEBUG - [FFMPEG] - Format avi probed with size=2048 and score=100
Aug 07, 2017 13:08:00.880 [22916] DEBUG - [FFMPEG] - use odml:1
Aug 07, 2017 13:08:00.982 [22916] DEBUG - [FFMPEG] - Before avformat_find_stream_info() pos: 10252 bytes read:1873116 seeks:5 nb_streams:2
Aug 07, 2017 13:08:00.983 [22916] VERBOSE - [FFMPEG] - Rescanning for external libs: '\\\\?\\C\:\\Users\\plex\\AppData\\Local\\Plex\ Media\ Server\\Codecs\\0affb08-1243-windows-i386\\'
Aug 07, 2017 13:08:01.034 [22916] VERBOSE - [FFMPEG] - Rescanning for external libs: '\\\\?\\C\:\\Users\\plex\\AppData\\Local\\Plex\ Media\ Server\\Codecs\\0affb08-1243-windows-i386\\'
Aug 07, 2017 13:08:01.088 [22916] VERBOSE - [FFMPEG] - Rescanning for external libs: '\\\\?\\C\:\\Users\\plex\\AppData\\Local\\Plex\ Media\ Server\\Codecs\\0affb08-1243-windows-i386\\'
Aug 07, 2017 13:08:01.088 [22916] VERBOSE - [FFMPEG] - Rescanning for external libs: '\\\\?\\C\:\\Users\\plex\\AppData\\Local\\Plex\ Media\ Server\\Codecs\\0affb08-1243-windows-i386\\'
Aug 07, 2017 13:08:01.170 [22916] DEBUG - [FFMPEG] - All info found
Aug 07, 2017 13:08:01.181 [22916] DEBUG - [FFMPEG] - After avformat_find_stream_info() pos: 24994 bytes read:1873116 seeks:5 frames:16
Aug 07, 2017 13:08:01.181 [22916] DEBUG - [MI]  * 3dbbd1a53bc39adde12b38c76ad53b239cc8d424 [avi mpeg4/ac3] Duration: 1782349ms, 576x432 (1.333333) 29.970fps, bitrate=1114kbps, audio channels=2, optimizedForStreaming=0 (C:\Users\Public\Plex-Tests\TV-Shows Wilson\Curb Your Enthusiasm\Season 2\Curb Your Enthusiasm - S02E06 - The Acupuncturist.avi)

Thanks sa2000. The log text below is what I get in Plex Media Server.log after a manual library scan. Am I missing something?

Aug 07, 2017 22:13:02.032 [0x7f4f13ff6700] INFO - AutoUpdate: no updates available
Aug 07, 2017 22:13:12.954 [0x7f4f0c7f8700] ERROR - downloadContainer: expected MediaContainer element, found html
Aug 07, 2017 22:13:12.955 [0x7f4f0c7f8700] WARN - DVR:Subscription: No container available for /tv.plex.providers.epg.onconnect:2/metadata/com%2Egracenote%2Eonconnect%3A%2F%2Fshow%2F13194214
Aug 07, 2017 22:13:12.956 [0x7f4f0c7f8700] ERROR - downloadContainer: expected MediaContainer element, found html
Aug 07, 2017 22:13:12.956 [0x7f4f0c7f8700] WARN - DVR:Subscription: No container available for /tv.plex.providers.epg.onconnect:2/metadata/com%2Egracenote%2Eonconnect%3A%2F%2Fshow%2F13809764
Aug 07, 2017 22:13:12.958 [0x7f4f0c7f8700] ERROR - downloadContainer: expected MediaContainer element, found html
Aug 07, 2017 22:13:12.958 [0x7f4f0c7f8700] WARN - DVR:Subscription: No container available for /tv.plex.providers.epg.onconnect:2/metadata/com%2Egracenote%2Eonconnect%3A%2F%2Fshow%2F12786888
Aug 07, 2017 22:13:13.567 [0x7f4f0c7f8700] ERROR - downloadContainer: expected MediaContainer element, found html
Aug 07, 2017 22:13:13.567 [0x7f4f0c7f8700] WARN - DVR:Subscription: No container available for /tv.plex.providers.epg.onconnect:2/metadata/com%2Egracenote%2Etms%3A%2F%2Fmovie%2FMV001499520000
Aug 07, 2017 22:13:13.722 [0x7f4f0c7f8700] ERROR - downloadContainer: expected MediaContainer element, found html
Aug 07, 2017 22:13:13.722 [0x7f4f0c7f8700] WARN - DVR:Subscription: No container available for /tv.plex.providers.epg.onconnect:2/metadata/com%2Egracenote%2Etms%3A%2F%2Fmovie%2FMV004746170000

Yes you are missing something !

Need to re-instate the default logging level for the server

Settings / Server / General / Show Advanced
Enable Debug Logging
Save changes

Thanks sa2000! I re-enabled the debug logging and was able to pull the values.