Shut down Plex / server

Server Version#: Linux debian 6.1.0-23-amd64
Player Version#: 1.40.4.8679
I want to be able to shut down the machine (thinkserver ts140) on which plex is running with home assistant.
As a first step I tried to shut down plex in the command line interface but was not able to.
I always get command not found.
Does anyboday knows how to …

  1. shut down the machine on which plex is running (besides the power button)
  2. shut down the machine with home assistant?

This works on Ubuntu, which is derived from Debian. No idea about home assistant.

sudo systemctl stop plexmediaserver.service
sudo poweroff

shutdown should work as well, if you want to shut down at a specific time.

man poweroff and man shutdown should show you the options for each.

if i try sudo poweroff or poweroff I get the message
-bash: sudo: command not found
and I dont know why.
If I type man poweroff i see the options explained.
Do I need to install a package to enable poweroff?

Look in /usr/bin for sudo.

If /usr/bin is not in the account path, you can specify the full path.

/usr/bin/sudo poweroff

l0newo1f@osage:~$ cd /usr/bin
l0newo1f@osage:/usr/bin$ ls -l sudo
-rwsr-xr-x 1 root root 232416 Apr  3  2023 sudo
l0newo1f@osage:/usr/bin$

Thanks for you answer.
Based on your information and further google search I found the solution:
Login with user then change to root with su and then systemctl poweroff.
Now I have to find a way how to shut it down via home assistant.

If I may augment here?

Do you have SSH capability in Home Assistant?

I ask because:

  1. I did ssh-copy-id admin@qnap
    – This gave me admin credentials in ssh with my normal linux workdstation username

  2. From my normal linux user, I can now ssh qnap poweroff

This will bypass the admin menu they present and execute whatever command is on the SSH command line

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