-
-
Save Deathproof76/bd547640e8a13d738dbee68fe8aef156 to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| # Plex busy DB workaround | |
| # Set the maximum number of allowed occurrences of the Sqlite3: Sleeping for 200ms to retry busy DB string | |
| # about 3 times usually indicates an instance that can't recover by itself | |
| # if your instance restarts your docker logs should reset, or "cover up" the busy DB lines, afaik | |
| MAX_OCCURRENCES=3 | |
| # this part "docker logs --tail 10 plex" "--tail 10" means the last ten lines of the container logs | |
| # of the container named "plex", change the name according to your setup | |
| # you can try "docker logs --tail 10 plex" in the terminal and if everything is setup correct | |
| # it will spit out the last 10 lines of the logs and should work | |
| LOG_LINES=$(docker logs --tail 10 plex) | |
| # Count the number of occurrences of the specified string in the log lines | |
| OCCURRENCES=$(echo "$LOG_LINES" | grep -o "Sqlite3: Sleeping for 200ms to retry busy DB." | wc -l) | |
| # If the health check fails, restart the plex container | |
| if [ "$OCCURRENCES" -gt "$MAX_OCCURRENCES" ]; then | |
| # Restart the container | |
| # Again this part "docker restart plex" assumes that your container is named plex, change the name according to your setup | |
| docker restart plex | |
| fi |
Im trying to use the script in unraid via the user scripts. is this the only part I need to modify "docker restart Plex-Media-Server" with the name of my container
Did you ever figure this out? As I have 2 plex instances I want it to watch both
you need two instances of the script in your case plexdb1_healthcheck.sh and plexdb2_healthcheck.sh for example. both need their own crontab entry. Also yes there are two cases in the script where you need to rename according to you instances name. I extended the commentary and explanations within the script
Im trying to use the script in unraid via the user scripts. is this the only part I need to modify "docker restart Plex-Media-Server" with the name of my container
Did you ever figure this out? As I have 2 plex instances I want it to watch both
you need two instances of the script in your case plexdb1_healthcheck.sh and plexdb2_healthcheck.sh for example. both need their own crontab entry. Also yes there are two cases in the script where you need to rename according to you instances name. I extended the commentary and explanations within the script
Thank you so much for your reply. So I have 2 container "plex" and "plex2" I made a second because I share with my family out of state and the first one gets this error so often I have the second so there is always a running instance. I even moved my appdata to the cache and it didn't fix it. I'm using unraid so I set this up as a userscript and used a cronjob to run it every minute. It seems to work fine on plex. So what exactly so I need to change for plex2 to work. It just reads the docker image right so no need to like link to the appdata or anything like that? I appreciate your help.
Did you ever figure this out? As I have 2 plex instances I want it to watch both