[arch-general] remote poweroff with systemd

Fons Adriaensen fons at linuxaudio.org
Tue Aug 6 11:18:39 EDT 2013


On Tue, Aug 06, 2013 at 01:56:09PM +0100, Paul Gideon Dann wrote:
 
> ssh -t remote1 "sudo systemctl poweroff && exit"
> 
> Technically I guess it's a race condition, but the command should terminate 
> and close the SSH session before OpenSSH is shut down, so you shouldn't get 
> the hang.
> 
> Alternatively, you could try "systemctl start poweroff.target" to see if that 
> returns quicker.  I'm not sure if the poweroff command returns straight away 
> or waits.  Basically, I'm thinking that if you can get the first command to 
> return quickly, your shell will close nicely before the shutdown kills the 
> connection.

Thanks to all who suggested solutions. 

What difference should the '&& exit' make ? The ssh will terminate
anyway when poweroff returns. Problem is that by then it's too
late.

I think the fundamental problem is that you just can't expect
'systemctl poweroff' or whatever variation of it, to return and
still have a clean system at that point.

So the explicit delay provided by the poweroff.timer unit seems
the right solution. And I like it because it doesn't rely on 
anything undocumented - it just uses systemd's features.


Ciao,

-- 
FA

A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)



More information about the arch-general mailing list