Plex Media Scanner CLI not working

Server Version#: 1.15.5.994

NAME=“Ubuntu”
VERSION=“16.04.6 LTS (Xenial Xerus)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=“Ubuntu 16.04.6 LTS”
VERSION_ID=“16.04”
HOME_URL=“http://www.ubuntu.com/
SUPPORT_URL=“http://help.ubuntu.com/
BUG_REPORT_URL=“http://bugs.launchpad.net/ubuntu/
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

I am unable to use the CLI to perform any action, a simple action just getting the list of library doesn’t work. I do not get any errors it just doesn’t work.

Can’t seem to fin any blog or forum where this issue is resolved. Any Help?

note: this is not PMS version or OS specific issue

One solution is to run it as the plex user.

if I do this:

sudo su plex

and then run the command it works (at least it does for me)

I am using a different user, i had tried that and root, no dice.

With sudo su plex it just hangs

ok, in that case have you tried exporting the path:

https://support.plex.tv/articles/201242707-plex-media-scanner-via-command-line/

export LD_LIBRARY_PATH=/usr/lib/plexmediaserver

Yup, tried all that.

If its working for you as plex user, i will create a new server for test with defaults and see it that works for me.

This is a snippet from when I just tried on my ubuntu 16:

blim@myserver:/home/blim$ /usr/lib/plexmediaserver/Plex\ Media\ Scanner --list
 40: Movies 4K
 46: Movies
 ....
1 Like

Must be the custom configuration on my end.

Time to review setup :frowning_face::frowning_face:

For the scanner to work:

  1. Environment variables (APP_SUPP_DIR) must be set
  2. Scanner must be invoked with the same UID PMS is running as.

I believe is have all those set and still have issues, PMS is running as msacc

Service Environment variables

/lib/systemd/system/plexmediaserver.service

[Service]
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support"
Environment=PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
Environment=PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
Environment=PLEX_MEDIA_SERVER_TMPDIR=/tmp
ExecStartPre=/bin/sh -c '/usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"'
ExecStart=/bin/sh -c '\
PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" \
PLEX_MEDIA_SERVER_INFO_DEVICE="PC" \
PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)" \
PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" \
LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib \
"/usr/lib/plexmediaserver/Plex Media Server"'

Override config

/etc/systemd/system/plexmediaserver.service.d/override.conf

[Service]
#  Move the data directory
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/msdata/Plex/Library/Application Support"
Environment=PLEX_MEDIA_SERVER_TMPDIR=/msdata/Plex/tmp
Environment=PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
export LD_LIBRARY_PATH=/usr/lib/plexmediaserver

Am i missing something??

Your override should not be touching LD_LIBRARY_PATH.
That export is invalid and incorrect syntax for a service override.
If you remove the export statement, that will make it correct.

You can omit the PLUGIN_PROCS change as the default is 6.

when you invoke the scanner at the command line, you need:

  1. as user plex (you must su to it)
  2. export all the environment variables as combined from the master service file with override adjustments
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/msdata/Plex/Library/Application Support"
export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
export PLEX_MEDIA_SERVER_TMPDIR=/msdata/Plex/tmp
export LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib   (on 1.15.0 + )

"/usr/lib/plexmediaserver/Plex Media Scanner"    --- options here ---

If i change the master file anytime i update i will have to redo it.

Been through this a while back, i believe you instructed me to do the override :smiley:

I wanted to do the scanner for an automation but if override and manual scanning can’t work together is will keep override.

that’s correct. I overwrite the master as fresh each time.

You will have to write your own “MyPlexScanner.service” file and put it in
/etc/systemd/system/MyPlexScanner.service

Using the same style as I have the, your ExecStart= will be the actual command line which you make work from the shell.
Your only customization will be to set as a periodic service with a timer value.

You can use the fstrim.service, which is a timed event, as a template.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.