#!/bin/bash
# Go to the PlexMediaServer shared folder
cd /var/packages/PlexMediaServer/shares/PlexMediaServer
# Go down further into AppData
cd AppData
# Make certain Plex is stopped
/usr/syno/bin/synopkg stop PlexMediaServer
# Remove the tmp directory then recreate it
rm -rf tmp
mkdir tmp
chown PlexMediaServer:PlexMediaServer tmp
# Now into "Plex Media Server" for more
cd "Plex Media Server"
# Let's clean up the Cache
cd Cache
rm -rf PhotoTranscoder
mkdir PhotoTranscoder
chown PlexMediaServer:PlexMediaServer PhotoTranscoder
To use:
Save the task after you’ve defined it
Highlight it but do not Enable (the checkbox)
Click “Run” and confirm to run it
Watch your email for completion report.
If you’re still missing space, We’ll make arrangements to figure it out.
Something nasty is afoot in there.
Sorry to be late getting to this, but it was too late to try to do it last night and I had stuff to take care of this morning.
In the meantime I was still running the delete effort from File Manager. It got up to almost 500,000 files and had freed up 18GB when I stopped it.
Having never done anything with user scripts before, your instructions were very well written and easy to follow and the script makes sense (I’ll assume it’s “right”).
It is now running and I will let you know what comes from it.
Any idea how long this will take? I don’t really care, but I want to be able to manage my own expectations.
On Synology, with its software RAID, file deletion can be very slow especially when there are TB of tiny files. 1TB / 1KB each would be 1 billion files.
The btrfs support blocks and structure to track 1 billion files alone is substantial.
Add to this – Synology physical disk i/o is not the fastest on a 2 bay NAS.
Wanted to provide a (hopefully) final update on this topic.
It finally finished. Took 9.5 days and I went from 0 free space, to almost 4TB (3.96 to be exact).
I’ve restarted Plex and it seems to be working (will probably take a while to replace the true files from the tmp directory (which were deleted along with the tens of millions of unneeded files). Hopefully this version of Plex will stop when done and then clean up after itself - I’ll be watching closely.
Again, thank you to Chuck, DJ and everyone else who provided input. Very appreciated. Would not have been able to do it without the support.
you may want to ask @ChuckPa if there is anything else you should do. i’d assume you may need to repair your database or something. Whatever was causing it to write to that directory constantly may not have been fixed just by deleting the directory.
Apologies for looping back onto this old post/topic - I checked the /tmp folder before and its was tiny (40MB?), but I never looked at the Transcode or PhotoTranscoder folders in Cache - I must have skimmed over this post previously.
Right now, for me, Transcode is empty (0 files, 2 folders), however PhotoTranscoder is somewhat large at 2.42GB (11933 files, 265 folders). Certainly when compared to the entire PlexMediaServer/AppData folder which stands at 7.64GB (39,337 files, 30259 folders), PhotoTranscoder is a hefty proportion.
Is that ‘OK’?
I also note that the files within the PhotoTranscoder sub-folders all seem to have modified dates within the last month.