Plex Media Scanner on Raspberry Pi

Server Version#: 1.15.3.876

Hi, sorry, am not great with Linux, still learning!

I’m trying to figure out how to use the Plex Media Scanner from the command line, eventually I would like to set up a script to run this (after using filebot to rename and move files).

Apparently, the script needs to be run as the ‘plex’ user, but this asks me for a password (which I don’t know?)

su plex -c "/usr/lib/plexmediaserver/Plex\ Media\ Scanner --list"

Is there a standard password for the ‘plex’ user? Or a way for me to find out what it is/reset? Or would that cause massive problems?
Can I create a new user with permissions to run this task? If so, how?

Not sure what to do next!

This one works for me. I think I found it here in the forums, but don’t remember where.

#!/bin/sh

PLEX_USER=plex
# PMS won't work unless it's run as user 'plex'
if [ "$LOGNAME" != "$PLEX_USER" ]; then
sudo su "$PLEX_USER" -c "$0 $*"
exit 0
fi
if [ -f /etc/default/locale ]; then
export LANG="$(sed -ne '/^LANG=/ s/LANG="\([^"]*\)"/\1/p' < /etc/default/locale)
"
export LC_ALL="$LANG"
fi
#this should be in /etc/default/plexmediaserver
export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}"
export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}"
$PLEX_MEDIA_SERVER_HOME/Plex\ Media\ Scanner "$@"

Save it as something like plexscan, then chmod +x plexscan to make it executable. Then you can run it with ./plexscan --list

It takes care of logging in the plex user for you.

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