On Tue, Aug 6, 2013 at 2:56 PM, Paul Gideon Dann <pdgiddie@xxxxxxxxx> wrote: > On Tuesday 06 Aug 2013 10:09:33 Fons Adriaensen wrote: > > 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" > > Have you tried something like: > > 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. > Or maybe "systemctl --no-block poweroff".