Automating PMS relaunch on Mac

Server Version#:Latest
Player Version#:Latest

Hello. I have a PMS set up on Mac mini and it runs fine but just randomly shuts down. I have tried to change a bunch of settings ie transcoding etc but it doesn’t help. Does anyone know an EASY way of automating the relaunch process ie. monitors the application if it shuts down it would automatically relaunch the PMS. Have tried to look for solutions but I have no programming skill and the solutions all seem super complicated and lack any kind of detailed instructions. HELP!!

Put it inside a shell script;

#!/bin/sh
while true
do
/Applications/Plex\ Media\ Server.app/Contents/MacOS/Plex\ Media\ Server
done

So when it exits it returns to the shell script which runs it again.

Now if I could find out how to start it on machine boot and not user login I’d be set.

Ok. Thank you. I may need some more guidance. I tried putting this in through automator as well as cutting and pasting into terminal. Nothing happens when I do it in automator and it tries to run but no luck

this is what I get when it goes in to terminal

Last login: Mon Dec 7 11:02:55 on ttys000

mikemitchell@Mikes-Mac-mini ~ % #!/bin/sh

zsh: event not found: /bin/sh

mikemitchell@Mikes-Mac-mini ~ % #!/bin/sh

while true

do

/applications/Plex\ Media\

Server.app/Contents/MacOS/

Plex\ Media\ Server

done

zsh: event not found: /bin/sh

mikemitchell@Mikes-Mac-mini ~ % #!/bin/bash

zsh: event not found: /bin/bash

mikemitchell@Mikes-Mac-mini ~ % #!

zsh: command not found: #!

mikemitchell@Mikes-Mac-mini ~ % #!/bin/sh

zsh: event not found: /bin/sh

mikemitchell@Mikes-Mac-mini ~ % #1/bin/zsh

zsh: no such file or directory: #1/bin/zsh

mikemitchell@Mikes-Mac-mini ~ % #!/bin/sh

while true

do

/applications/Plex\ Media\

Server.app/Contents/MacOS/

Plex\ Media\ Server

done

zsh: event not found: /bin/sh

mikemitchell@Mikes-Mac-mini ~ % #!/bin/bash

while true

do

/applications/Plex\ Media\

Server.app/Contents/MacOS/

Plex\ Media\ Server

done

zsh: event not found: /bin/bash

mikemitchell@Mikes-Mac-mini ~ %

Any suggestions?

Mike

You know what. Never mind. I copied and pasted your script into automator and it worked! Thank you!! so will this just force plex to open if it crashes? Again thank you very much!!

I didn’t really think about using automator, you could possibly do the whole thing in automator and not need any shell.
Just to clarify my answer, here are more detailed instructions copy and paste that code into a text file. I do mean plain text, not RTF, so if you are using TextEdit make sure you make the file plain text (under format menu) shift-cmd-t
Save the file to start-plex.cmd you may need to rename it in finder, as Textedit likes to put .txt on the end of the filename.
I haven’t been able to work out how to do this next step in anything else but terminal. We need to change the permissions of the file you’ve just created. We need to enable the “execute” permission. so the command to enter in the terminal is;

chmod +x start-plex.cmd

Although you need to specify the path to start-plex. The easy way to do this is find the file in the finder, enter into terminal: chmod +x
(with an extra space on the end) then Drag the file from finder into the terminal;
you should then have a line that looks something like this;

chmod +x /Users/mark/Desktop/start-plex.cmd 

The command is successful if it returns you immediately to a prompt, without any messages. Now you should be able to double click it to start.
After I had written this answer I then thought of creating a LaunchAgent, with a KeepAlive, so that Plex will automatically start, upon login and will be restarted by launchd if it happens to exit. I haven’t tried out this idea yet, so it may not be a viable solution.
If it does work I’ll update this answer with a solution that uses a LaunchAgent.

and I can’t fix my formatting errors, nor could I find where to preview my post either. sorry about that.

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