If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

I need a way to restart the plex server IF it stops.

LeroyWeberLeroyWeber Posts: 4Members, Plex Pass Plex Pass

My PLEX server on Freenas is installed through the plugin. For the last few updates (I'm now on FreeNAS 11.0-U4 and Plex Media Server 1.9.4.4325 on a plex pass) the Plex Media server shuts itself off periodically. Sometimes it shuts off every day and sometimes it shuts down once a week. How can I make a script or cron job that checks to see if the PLEX media server is running and , if it is not running, restart the plex server?

Answers

  • nokdimnokdim Posts: 907Members, Plex Pass, Plex Ninja, TunerTester Plex Ninja

    It sounds more like your plex is actually crashing from time to time?!?!? You could ignore and just build some script to kick it off again or post and look into the log files and see if you can find a cause for it crashing.

  • ChuckPAChuckPA Posts: 17,711Members, Plex Pass, Plex Ninja, Plex Team Member Plex Team Member

    In the script,

    if [ `pidof "Plex Media Server"` -eq 1 ]; then
      echo PMS isn't running
    fi
    

    Console output showing when PMS is running. pidof prints the pid number and $? is zero (no error)

    [/share/CACHEDEV2_DATA] # ps -ef | grep Plex
     1233 admin     71860 S   ./Plex Media Server
     2418 admin     51728 S N Plex Plug-in [com.plexapp.system] /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-9798172d4/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.9.3.4290-9798172d4 /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-9798172d4/System.bundle
     2483 admin     29760 S   /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Plex DLNA Server
     2484 admin     15288 S   /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Plex Tuner Service /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Resources/Tuner/Private /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Resources/Tuner/Shared 1.9.3.4290-9798172d4 32600 /waitmutex
    28564 admin       880 S   grep Plex
    [/share/CACHEDEV2_DATA] # pidof "Plex Media Server"
    1233
    [/share/CACHEDEV2_DATA] # echo $?
    0
    [/share/CACHEDEV2_DATA] # 
    

    Please DISABLE Verbose logging until requested

    Please search before posting

    Primary support forums: Linux, Synology, and QNAP

    Please remember to report back. This benefits others.

    Useful links

     Installation and Basic Setup |  Media Preparation (How to name your media files)  |  Linux Permissions 

     Handling TV Specials | Handling Movie extras  |  Nas Compatibility List

     Reporting Plex Server issues | Plex Media Server FAQ | Linux Tips

     

    Other useful guides: Local Subtitles | The Plex "dance" | Synology FAQ | PMS Release Announcements

    No technical support via PM unless offered

    Please remember to mark the appropriate answer(s) which solved your issue.

     
Sign In or Register to comment.