[arch-general] remote poweroff with systemd

Fons Adriaensen fons at linuxaudio.org
Tue Aug 6 06:09:33 EDT 2013


On Tue, Aug 06, 2013 at 12:31:20PM +0530, phanisvara wrote:
> On Monday 05 Aug 2013 18:39:22 Fons Adriaensen wrote:
> > ssh -t remote1 "sudo /sbin/init 0"
> > ssh -t remote2 "sudo /sbin/init 0"
> > 
> > etc. This has worked well for years.
> > 
> > Recently the machines were upgraded and mow use systemd.
> > I replaced the original commands by
> > 
> > ssh -t remote1 "sudo telinit 0"
> 
> i've had problems with clean shutdown since systemd, too, and what's 
> working for me i "shutdown -h now" instead of the systemd commands 
> i've come across. i'm using this on virtual machines only, but don't 
> see why it shouldn't work on real remote boxes as well.
> 
> this doesn't hang the ssh session, or cause any other problems i've 
> seen yet.

Tried it, it does hang the ssh session here.

Also tried systemctl --host. This makes systemd complain rather 
clearly about unit files being modified and other havoc.

But I found a very systemd-ish solution:

On the remote machines I have /etc/systemd/system/poweroff.timer

----
[Unit]
Description=Delayed poweroff

[Timer]
OnActiveSec=5
Unit=poweroff.target
----

and the script does

ssh -t remote1 "sudo systemctl start poweroff.timer"


As this is the first systemd unit file I wrote it can probably
be improved, all suggestions from the experts are welcome.

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