I am running a plex media server for private use on a Ubuntu 16.04 Desktop VM at home. I use it while I'm away on work during the week.
Recently I've been plagued with connection issues. Sometimes it's plex itself that crashes and needs to be restarted and sometimes it's the internet connection (eth0) that needs to be restarted.
I need a little help with a script that I can call via cron to check if the server is remote accessible, if it can reach https://external.address:32400 (please note it only responds to https), if it's not accessible, restart the internet connection (eth0), then check again if it's remote accessible, if it's still not remote accessible then restart the plex media server.
Plex is installed as a service so the call service plexmediaserver restart
is how I restart it. I guess as it's a desktop instalation to restart the network the script needs to use service network-manager restart
.
I found this post and script but it's very old and outdated.
Hopefully someone can help me out with this.
Thanks in advance.