script to check if Plex is running, hung, or crashed on MacOS then restart it as needed
Save this script as a shell script file (e.g., plex_monitor.sh) and make it executable using chmod +x plex_monitor.sh. You can run this script in the background by executing ./plex_monitor.sh & in your terminal. It will keep running in the background and monitor the Plex Media Server indefinitely.
Add to MacOS login items for your user profile so it runs automatically
##Note
This code be used for other programs besides Plex by editing the script to your needs