Plex devs, can you back out a change in 1.31.0.6654?

Server Version#: 1.31.0.6654
Player Version#: n/a

With this new version, I saw this item:

(Linux) Automatic library updates are now triggered by filesystem permissions and ownership changes (#14045)

… this is killing my server. Every hour I have a cron job that does a ‘chmod 755’ on all my media because every now and then, I’ll add something and the permissions get screwed up on the copy. So my cron job comes around every hour and does its’ magic and everything always shows up in Plex.

With this new add, my server refreshes all my libraries (and thousands and thousands of files) every hour and navigating around in the console is super slow during this time.

Any chance you can pull that add back out?

Can you change your cron job to check permissions first, and change only if necessary?

I did a quick Internet search.

find \! -perm 775 -type d -exec chmod 775 {} \;
find \! -perm 664 -type f -exec chmod 664 {} \;
2 Likes

Something needs fixed on your end. You shouldn’t need to run that script in the first place is everything was ‘correctly done’. I would look into your process and figure out why the permissions are not what they should be in the first place.

While Ford’s solution will work, I would highly encourage you to figure out why you need to do this in the first place. That permission cronjob is a band-aid ‘hack fix’ instead of ‘fixing the real issue.’ Sure, it works for you, but you shouldn’t even need to do that if things were ‘correct’.

If I may add?

Sonarr / Nzbget / many other tools will set permissions correctly when writing.

Permissions can also be set to be inherited automatically

I think you’ll find this a slick trick :sunglasses:

1 Like

How are you adding those files? I used to have that problem long time ago with Sonarr/Radarr, but I fixed it by fixing the permissions in Sonarr/Radarr itself after doing the copy.

Thank you for the info!

I created some test directories and placed files in each (that are NOT 755) and executing this command:

find /mnt/md0/1/ /mnt/md0/2/ /mnt/md0/3/ -type f -not -perm 755

… correctly displayed the files that don’t have 755 but how do I tie it together and then take chmod action on the results?

find /mnt/md0/1/ /mnt/md0/2/ /mnt/md0/3/ -type f -not -perm 755 && chmod 755 ??????

Of course that will fail because chmod needs to know the path. Going to do some Googling in the mean time.

While I’ve been running my Plex server on Linux for many years, I still consider myself somewhat of a newbie with it. :slight_smile:

While I -do- have Sonarr and Radarr set to change file permission to 755 … on rare occasions (and for whatever reason), they don’t do it all the time. It works 99% of the time but sometimes, files fall through the cracks.

Or, if I manually download something and copy it into my movie folder, it won’t have the ‘execute’ bit set and Plex won’t see it until I fix that. I know, I know… the Plex support link about Linux permissions doesn’t list the execute bit as needed…so long as Plex has read access to the file, it will see it. Unfortunately, it doesn’t work that way for me. The overwhelming majority of times, Plex does indeed need just read permissions on the file but on super duper rare occasions, it won’t see a file until I make it executable. I don’t want to go down that rabbit hole :slight_smile: … my chmod cron job was working perfectly and all media was showing up just fine. Just need to figure out a way to get back on track.

Add -exec before the chmod command.

Look at the examples in my first post. You should be able to add the paths and they should work.

sudo find /mnt/md0/1/ /mnt/md0/2/ /mnt/md0/3/ -type f -not -perm 755 && -exec chmod 755

/mnt/md0/1/blah
/mnt/md0/3/fasdfaf
bash: -exec: command not found

Every… and I mean EVERY :slight_smile: time I mess with setGID/sticky bits I somehow make matters worse. lol

When i first started using Linux and Plex (and didn’t have a full grasp of file permissions and inheritance), I played around with those commands and spent a few frustrating hours trying to get it right. I wasn’t using the guide you linked to so maybe a few years of experience and having a better understanding of things will make it better this time around? But, I’m like lightning… I prefer the path of least resistance. If I can get my cron job back up and running, I’ll probably stop there. If that it too difficult, back to sticky land. :slight_smile:

Is checking permissions any less expensive than just unconditionally changing them?

Nothing special… I just go to web site XYZ and download a file and copy it into the appropriate media folder and the execute bit needs set. Other times, Sonarr/Radarr fail on setting the 755 file permission even though they’re configured to do it.

Say i add 20 media files to my Plex server every day, 7 days a week. Odds are ONE of those files will need their permissions fixed. It happens enough where it was a minor nuisance and my simple cron job caught the strays.

See first post in thread. OP wrote that unconditionally setting permissions results in Plex re-scanning the libraries. Checking first, and changing only when necessary, will hopefully avoid unnecessary scans.

DUH… :slight_smile: sorry, I got fixated on the wrong part of that post. That did the trick! Thanks a million!

For future travelers:

find /mnt/md0/1/ /mnt/md0/2/ /mnt/md0/3/ ! -perm 755 -type f -exec chmod 755 {} \;

… that command will look for files that DON’T have 755 permissions and give it to them, and only them, in one shot.

1 Like

You shouldn’t even need to do this. Even if you run them in docker, you can pass the uid/gid it will use, everything created under the container will have that id. If you use linuxserver containers, add PGID=1000, PUID=1000 to the env vars (or w/e your uid is)

You shouldn’t need to use the ‘bandaid’ chmod feature in sonarr/radarr either. None of that should be needed for the vast majority of setups use-cases.

Now that you have a temp fix. I would highly recommend fixing your setup so you don’t need to modify permissions at all. You can run docker, radarr, sonarr, rclone, mergerfs, etc as a user so no permissions need to be changed at all by script or by radarr/sonarr/sab, etc themselves.

Thats just a bandaid on a problem that can be fixed in a better way.

I have no doubt it can be fixed better but I detest dockers (tried to set things up before using them and had bizarre problems) and I’m OK with my band-aid solution. For now. :slight_smile:

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