Plex Server Container (UnRAID) scans entire library every hour

Server Version#: 1.31.1.6733
Player Version#: 1.65.1.3596-7b1f6d97

Since the server update in late Jan-Early Feb (when scan credit was released), my Plex Server will scan my entire Television library every hour, seemingly exactly. This causes paused drives to spin up and waste time and power, and seems to not honor the settings I’ve placed in the Library settings section. Whenever I have “Scan my library automatically” checked, it will always scan the entire Television library even if I have “Scan my library periodically” unchecked, or set to “Daily” for the interval. “Run a partial scan” doesn’t take effect unless the “scan my library automatically” is checked. Is this a behavior change or something wrong with my configuration? I didn’t make other changes during that time, so I’m fairly confused regarding this. Happy to post any logs that would be helpful, but I’m not sure which ones to get and from where.

Thanks.

I’ve not seen any reports of this anywhere (but could have missed it)

Do you have a cron job which sets file permissions anywhere / changes the date/time stamp on files or directories ?

PMS is now sensitive to both permission changes and modification through the ‘inotify’ kernel service.

My unraid sits here quietly unless I add / do something to wake it up

Ah! Yes, I do since I’m often writing to it from a Windows domain machine and I change the acls on any added directories to be owned by a media account/domain users group. Does that also trigger when the account sets permissions but hasn’t changed anything?

Coincidentally enough, the script runs exactly every hour… I’ll disable it now and see if the issues end. Was that change made around January/February?

Yep… In February.

I’ve been helping folks understand that they need to change their tools to either

  1. Write the correct permissions the first time (BEST)

  2. If they must perform scans, look for permissions which aren’t correct and only change those. (sledgehammer technique no longer works well)

Someone recently posted some shell code that checked permissions and only changed those that weren’t of the desired value, but I can’t find it.

Anyone remember the thread or post?

I’d definitely like to know this code so I don’t have to re-create it. While I’d definitely prefer to get the correct permissions written the first time, setting group permission inheritance on a folder (the main thing I’m concerned about) doesn’t seem to work well in UnRAID when dealing with AD group mappings and creating subdirectories from a Windows machine, for some reason.

For Plex use,

directories 755, files 644 is plenty.

find  <dir_names_here>  -type d  \! -perm 0755 -exec chmod 755 {} \;

Adjust appropriately for files

Example:

[chuck@glockner Databases.2001]$ find /vol/media -type d \! -perm 0755 -print
/vol/media/animated/Lightyear (2022)
/vol/media/animated/The Lego Star Wars Holiday Special (2020)
/vol/media/animated/Hotel Transylvania Transformania (2022)
/vol/media/animated/The Ice Age Adventures of Buck Wild (2022)
/vol/media/animated/The Bugs Bunny Road Runner Movie (1979)
/vol/media/animated/Atlantis Milo's Return (2003)
/vol/media/animated/Minions The Rise of Gru (2022)
/vol/media/animated/Puss in Boots The Last Wish (2022)
^C^C^C^C
[chuck@glockner Databases.2002]$ ls -la /vol/media/animated/Lightyear\ \(2022\)/
total 19482404
drwxrwxr-x   2 chuck chuck          42 Aug 13  2022 ./
drwxr-xr-x 128 chuck chuck        8192 Jan  7 19:26 ../
-rw-rw-r--   1 chuck chuck 19949968115 Aug 13  2022 Lightyear (2022).mkv
[chuck@glockner Databases.2003]$

Please do try to get your tools in order such that they set the correct perms at creation time. (Sonarr/Radarr do this very well)

Thanks. I’ll see what I can do with that.
I don’t use any of the rr’s currently as most of my work is backing up DVD’s/BluRays from my personal collection. My largest concern is getting directories set up there for the rest of my family to be able to add to or read the files from shares to Windows machines. If I could get it to work when I create a directory on a share to have the proper group, I definitely would. Unfortunately I’m still learning some of the finer details of Linux ACL management and haven’t been very successful in getting proper setups from the Windows side of things just yet.

Thanks.

Might I ask why you need Linux ACLs on your media server?

Do you have that many people accessing it such that normal Linux-mode OGW permissions aren’t sufficient ?

Also, have you seen?

(this is the setuid/setgid/setperm feature of the kernel and works extremely well with Plex)

I have 5 members of my household accessing the media folders at arbitrary times, but not frequently. Part of this exercise to move to a Linux/container setup was for my own knowledge expansion into the Linux ecosystem coming from 25 years of experience in Windows and network security and administration.
Currently, when I create a new directory to transfer video files into the UnRAID share that holds my media collection, it’s created with the mapped AD user and higher access default group of my Windows account; this makes it inaccessible from other members of my household until the permissions on the directories and files are reset. While I can do that manually I’d prefer to have a script reset the permissions; I’d LOVE to have it just set properly when I write it at first, though.
Plex reads it fine as the container is running as an account with a higher permissions level, but that’s something I’d like to secure eventually in the future as well.

I hadn’t seen the Linux Tips you linked. I’ll peruse that when I get a bit of time.

Worst case, I can just use my cron job once a day (or less frequently even) rather than hourly, which should get the job done and not cause the constant library refreshes.

Regarding PMS being sensitive to permissions changes, I’m not yet convinced what it buys us anyway.

I’m going to follow up on that internally and see if I can convince them it’s not needed.

Thanks Chuck! I can see it being useful for larger libraries, especially when talking about the extended directories and files that music libraries can create. If it solves the problem of the “maximum number of directories watched” issue…

Perhaps there’s a way to do a partial scan only on those directories that actually changed permissions, instead of those that were just updated with the same information, but I’m not sure if it’s worth kludging together a solution if the linux inotify kernel service doesn’t return a separate result for that.

Given the attributes it monitors for are:
(from <sys/inotify.h>)

IN_CLOSE_WRITE | IN_CREATE | IN_MODIFY | IN_DELETE | IN_MOVE | IN_ATTRIB

Partial scan triggers on notify events when

  1. The media is on a file system which the kernel can extend a inotify user_watch
  2. fs.inotify.max_user_watches table is not full.

At minimum, even partial scan is going to check all the directories in the known tree structure and compare date/time stamp.

If the date/time has changed then the contents of the directory has changed – so it knows it must start scanning here

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