With the help of Google, I was able to piece together a solution for preventing my Linux computer from sleeping while streaming something via Plex.
My workflow right now is to use an app called Wake Me Up to send a wake-on-lan signal to my Linux computer running Plex Media Server, which allows my Plex client apps to discover the server. The server won't go to sleep while there are any streams running from the server as long as the service defined below is running.
- Enabling Wake-on-LAN
- Original post for creating the service
- Instructions for finding your own Plex token
Note in order for the service to run, you need to make sure that curl
is installed, and that you have set the environment variable X_PLEX_TOKEN
(see references section above for how to find your token).
One way to do this is by running the following command in your terminal (assuming you use bash
)
echo "export X_PLEX_TOKEN=PasteYourTokenHere!" >> ~/.bashrc
source ~/.bashrc
Save the file plexkeepawake.service
inside the directory /etc/systemd/system/
(you'll need to use sudo
).
Start the service. Note that by using the keyword enable
, the service will start now and any time the computer reboots.
systemctl enable plexkeepawake.service
Hi Evan, how are you? I've managed to follow your instructions and got my server to prevent from sleeping while plex is streaming, but I realized that once it prevents from sleeping, then it never goes to sleep again, even if plex is no longer streaming. Do you know what this behavior could be due to?
Thanks!