Server Version#: 1.32.5.7210
Player Version#:
TL;DR - Have you made a script or would you like to proofread a script to monitor Plex Media Server.exe process and loopback address?
I’m curious if anyone else has experience creating a script to monitor the Plex Process or loopback channel?
A little back story, I am setting up my server to shutdown automatically at 4:00am and turn back on at 6:00am. There have been a few times for one reason or another that the service doesn’t seem to be on or accessible remotely. I worked with ChatGPT to create the following script to monitor the process and loopback automatically.
Has anyone else developed something like this? If not and you’re script savvy, would you mind looking over the below code?
@echo off
setlocal enabledelayedexpansion
REM Set the path for the log file
set log_file=monitor_log.txt
:monitor
timeout /t 10 >nul 2>&1
REM Check if Plex Media Server process is running
tasklist /fi "IMAGENAME eq Plex Media Server.exe" | findstr /i "Plex Media Server.exe" >nul 2>&1
if not errorlevel 1 (
echo %date% %time% - Plex Media Server process is running. >> %log_file%
) else (
echo %date% %time% - Plex Media Server process is not running. Starting the process... >> %log_file%
start "" "C:\Path\to\Plex Media Server.exe" >> %log_file%
echo %date% %time% - Plex Media Server process has been started. >> %log_file%
)
REM Check if the loopback address with port 32400 is reachable
ping -n 1 127.0.0.1:32400 >nul 2>&1
if not errorlevel 1 (
echo %date% %time% - Loopback address with port 32400 is reachable. >> %log_file%
) else (
echo %date% %time% - Loopback address with port 32400 is not reachable. Restarting the process... >> %log_file%
taskkill /f /im "Plex Media Server.exe" >nul 2>&1
timeout /t 5 >nul 2>&1
start "" "C:\Path\to\Plex Media Server.exe" >> %log_file%
echo %date% %time% - Plex Media Server process has been restarted. >> %log_file%
)
endlocal
goto monitor
Furthermore, I am aware that there are some variables / strings that would need to be altered to fit my environment.
Thanks in advance!