Plex Server Crash on Windows 10 - Watchdog Script to restart

Server Version#: Version 1.27.1.5916
Player Version#: Web Player Version 4.76.1

I have had crash issues with the Plex Server on my Windows 10 computer, as have many other folks. I wanted to post the restart job that I set up in Task Scheduler, and the powershell and VB script that I found to work for my circumstances. YMMV, please test before you use the script.

Powershell script, saved as StartPlex.ps1:

$Prog = "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe"
$Running = Get-Process prog -ErrorAction SilentlyContinue
if (!$Running) {Start-Process $Prog}

In order to launch the powershell script without a window popping up on the screen, you can call the .ps1 file from a VB script. Got the VB script from this site: Stack Overflow How to Run PS Script Without Window

VB Script, saved as ps-run.vbs:

Set objShell = CreateObject("Wscript.Shell")
Set args = Wscript.Arguments
For Each arg In args
    objShell.Run("powershell -windowstyle hidden -executionpolicy bypass -noninteractive ""&"" ""'" & arg & "'"""),0
Next

I set up a Task Scheduler task;

Create Task
General Tab:
Name: Check Plex Server Status
Run when the current user logged into the computer

Triggers Tab:
One Time, set start date and time
repeat task every 5 minutes indefinitely
Enabled checked

Actions Tab:
Start a program
Program: wscript
Add Arguments: c:\yourdirectory\ps-run.vbs c:\yourdirecctory\StartPlex.ps1

Conditions and Settings tab defaults.

When I stop the Plex Server, and let the task run, it starts it right back up. I had it crash last night, and the script got it back within the 5 minutes.

Good luck, hope this can help someone.

3 Likes

The problem I have is that the server crashes, it becomes inaccessible but the process is still Up, I made a similar script but it’s not working.

I used an app called “processalive” that automatically relaunches any app. HOWEVER, it relaunches instantly and that can cause problems. When Plex would try to update, it closes itself but the app would reopen it causing it to freeze.

I gave up on it and now just use AnyDesk to remote login if I have to restart PMS.

Yep, I can imagine that would be an issue. I also looked into putting in a check for hung process / not responsive, etc., but I haven’t had that happen yet so I didn’t work on it. I know there are commands out there to do that, just have to try them out. Testing is another issue altogether… lol

I can imagine that would cause issues, especially when it’s updating or if you want to close it manually… I tried different times with running the task scheduler and 5 minutes seemed to work okay.

David-
Is there a more newbie friendly way to do this? I like the idea of your script checking every 5 minutes and restarting if needed, I literally have no idea what you are saying on how to accomplish it. :sweat_smile: Is there a powershell for beginners tutorial somewhere? Thanks again.
Bruce

(Windows) Here is a reddit thread with a Tautulli script to reboot the PMS app. Tautulli can recognize the crash even though the app doesn’t close, so this is the best / easiest way to automatically reboot. I’ve tested it and it’s worked for me twice.

https://www.reddit.com/r/PleX/comments/waf50q/a_tautulli_script_for_the_people_experiencing/

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