Last active
March 26, 2025 16:24
-
-
Save Deathproof76/bd547640e8a13d738dbee68fe8aef156 to your computer and use it in GitHub Desktop.
Crontab restart/repair script for Plex "Sqlite3: Sleeping for 200ms to retry busy DB"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.