Plex Media Scanner CLI performance

Server Version#: 1.22.2.4282
Player Version#: Mac, iOS and AppleTV 7.15(23220) as primary

I moved my Plex server to the cloud with a Ubuntu 18.04 server and rclone Google Drive storage about two years ago. Over the past month or so I’ve been experiencing GDrive bans which I believe has to do with excess scanning. The cause of this is not as yet nailed down. Even with all scanning and analysis being turned off, I still seem to be moving files into the rclone cache which I am not viewing.

As a work around I’ve attempted to turn off all scanning and generate scripts using the Plex Media Scanner CLI. While testing my scripts I am puzzled as to why scanning for a single file is much slower than scanning an entire directory? Here are examples of two invocations of the Plex Media Scanner.

Here scanning for a single file which was previously added to a media folder:

time /usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan  --file /home/gd_mounts/tv_mydrive/tv_current/B\ Positive/Season\ 1/B\ Positive\ -\ S01E13\ -\ Inflammatory\ Response\ WEBDL-720p.mp4

real	1m10.354s
user    0m17.154s
sys     0m5.878s

Or here scanning the entire directory after having added a single file to the media folder:

time /usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan --section 17 --directory /home/gd_mounts/tv_mydrive/tv_current/Clarice/Season\ 1/

real  0m4.017s
user  0m0.420s
sys   0m0.056s

The single file performance is consistently significantly slower. I have run this multiple times with the current version and the same result.

The scanner settings for the library in question are set to “Plex Series Scanner” and “TheTVDB”.

Any thoughts or suggestions? Should I switch to the Beta Scanner? Any thoughts as to other things which might cause PMS to want to read files which are not being viewed? I only have video libraries (movies, tv, and personal) no music.

There is no --file parameter for scanning. Your first example is scanning all your libraries because you aren’t providing it with a section id or directory.

The second example is the correct way.

Also you should be adding --refresh otherwise it won’t update the metadata correctly.

Thanks for the quick response. In researching this I had relied initially on this Plex Article which still shows --file. And when I used a section id with --file ran into “Error: Cannot select file and something else.” Which led me to this forum post which seemed to indicate that the cause of my error was including section. However, if I had done --help for the scanner it now no longer displays the --file option. Although, given that I have 29 libraries and 10s of thousands of items I really doubt my errant use of “–file” was scanning all my libraries. Also note, the errant command did update the library and metadata. In any event, I will only use --section and --directory going forward.

As to your suggestion that I use both --scan and --refresh, I had not been using --refresh because I didn’t want update the metadata for entries in the directory which already have metadata. I only want metadata to be retrieved for entries without metadata. Am I misconstruing the use of --refresh when invoking the scanner with a section id and --directory? Also, could you clarify the use of --force and the difference between --refresh with and without --force?

Thank you.

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