error in terminal shutdown commands

Raspberry Pi related support

error in terminal shutdown commands

Postby Cyborg_delta1 » 12 Sep 2020, 00:18

Hello

I have a setup where I have runeaudio on a Pi3 in a audio rack (call it Pi1) and use another Pi as just an interface (call this Pi2) in another location. Now to shut down both Pi's at the end of the night I have created a bash script on Pi2 which will SSH to Pi1 tell it to stop playing, clear the playlist and shutdown then run a shutdown command on it self how ever I have ran into an issue.

If I tell Pi1 via ssh to "shutdown now" it will make the script hang on Pi2 and will not complete but if I use "shutdown +1" to delay the shutdown on Pi1 and allow the ssh connection to drop the script will bring back an error and Pi1 will remain on but the script will finish and Pi2 will shut down.

this is the error I get when I try to use anything but "shutdown now" I have also tried using sudo;

Failed to set wall message, ignoring: Unit systemd-logind.service is masked.
Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Unit systemd-logind.service is masked.

Any one know how to get this to work your help will be much appreciated?
Cyborg_delta1
 
Posts: 14
Joined: 29 Oct 2018, 16:53

Re: error in terminal shutdown commands

Postby Cyborg_delta1 » 28 Sep 2020, 23:35

Ok I have solved it my self

I can not believe how simple this was :roll:

If any one ever wants to do some thing similar this is how I got around it

Digging deep into the internet there are many many people with the same issue where asking a remote Linux machine via ssh to do a timed shut down results in an error and there does not seem to a fix for this. So instead of doing a timed shutdown I had to use the shutdown now command but this would make the script hang because it was waiting for a response from a shutdown system so all I had to do was change

Code: Select all
 ssh -t root@000.000.000.000 'sudo shutdown now'


to;

Code: Select all
 ssh -t root@000.000.000.000 'sudo shutdown now' &


when I found this out I was like WHAT..... THE..... FUCK..... a god dam $ sign that is all that stood in my way. For those who did not know like me this $ sign at the end of the command tells the shell run it in the background and carry on regardless if you get a response or not.
Cyborg_delta1
 
Posts: 14
Joined: 29 Oct 2018, 16:53

support RuneAudio Donate with PayPal


Return to Raspberry Pi

Who is online

Users browsing this forum: cmh714 and 10 guests