Скрипт не работает для cron, чтобы не дать серверу не спать во время потоковой передачи mov ie на медиа-сервер PLEX - PullRequest
0 голосов
/ 18 марта 2020

Я изменил время ожидания в спящем режиме на 3 часа, используя приведенную ниже команду, но когда мы перебираем фильмы, сервер переходит в режим ожидания go, и в этот момент я открываю приложение маршрутизатора и использую функцию пробуждения по локальной сети.

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-a c -timeout 10800

Мой друг написал мне этот сценарий, и я следовал за письмом ( даже выполняя команду sudo в строке 37), но сценарий не имеет значения, когда я переключился на более короткий тайм-аут, тестируя его. Будем весьма благодарны за любые лучшие методы или предложения, чтобы этот скрипт работал. Отставной ветеринар / полный уход за моей мамой с болезнью Альцгеймера. Помогите! : -)

#!/bin/bash
#
# plexmediaserver_keepalive
#
# This script should be set to execute each minute by the cron daemon; it will check to see if 'plexmediaserver' is running (due to periodic timeouts if the server
# is not in use). If it is running, then no action is taken; if it is not running, then the script restarts it.
#
# Using the sample 'ps -ef' output from Mike Powell's server, it shows that column 1 is the 'plex' user; column 8 is the Plex Media Server executable; we'll need to search for these to see if the service us running or not.
# plex 1747 1 1 Mar03 ? 00:31:49 /usr/lib/plexmediaserver/Plex Media Server

# Here we set variables to be the values that we know are the Plex Media Server user and application.

SET_USER = "plex" SET_EXEC = "/ usr / lib / plexmediaserver / Plex Media Server"

# Here we set a variable to be the result of a search for the 'plexmediaserver' processes that are running, if any.

PLEX_STATE = ps -ef | grep "/usr/lib/plexmediaserver" | head -1

# Here we set a variable to the 'user' column and to the 'exec'utable column of the processes that are running.

PLEX_USER = echo $PLEX_STATE | awk '{print $1}' PLEX_EXEC = echo $PLEX_STATE | awk '{print $8}'

# The following outputs are commented out on purpose; uncomment them to troubleshoot the script.
# echo Set User is $SET_USER
# echo Set Exec is $SET_EXEC
# echo Plex State is $PLEX_STATE
# echo Plex User is $PLEX_USER
# echo Plex Exec is $PLEX_EXEC

# Here we determine if the set user 'plex' is equal to the user we searched for in the processes running 'plexmediaserver' AND the set executable
# is equal to the executable we searched for. If the user AND the executable are equal to each other, then we know the Plex Media Server is running,
# otherwise it's not and we need to restart it.
if [ $PLEX_USER == $SET_USER ] && [ $PLEX_EXEC == $SET_EXEC ]
then
echo "Plex Media Server is already running" > /dev/null 2>&1
else
echo "Re-starting Plex Media Server..." > /dev/null 2>&1
systemctl start plexmediaserver
fi
...