Date: Mon, 3 Nov 2014 21:13:34 -0800 From: Kevin Oberman <rkoberman@gmail.com> To: Denny Lin <dennylin93@hs.ntnu.edu.tw> Cc: FreeBSD Ports ML <freebsd-ports@freebsd.org> Subject: Re: SSH hangs while restarting services Message-ID: <CAN6yY1tuewKkL-%2BAVAgmX-b3Lo7edR6wFxOO3zyeH4S6BjjqzA@mail.gmail.com> In-Reply-To: <20141104004803.GE3153@mail.hs.ntnu.edu.tw> References: <20141104004803.GE3153@mail.hs.ntnu.edu.tw>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Nov 3, 2014 at 4:48 PM, Denny Lin <dennylin93@hs.ntnu.edu.tw> wrote= : > Hi, > > Recently I've been trying to restart services remotely using SSH using a > command instead of entering the shell: > ssh host "sudo service postgresql restart" > > PostgreSQL is able to restart successfully, but SSH just hangs there > instead of exiting. I've noticed that this seems to affect any command > which spawns a child process which doesn't exit. > > Is there any way to get SSH terminate? Thanks. > > -- > Denny Lin > Try "ssh -f host "sudo service postgresql restart". If a socket is open, ssh will not exist and something in the startup is leaving something link STDOUT open. Use of '-f'' should work around this issue. From ssh(1): -f Requests ssh to go to background just before command execution= . This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. This implies -n. The recommended way to start X11 programs at a remote site is with something like ssh -f host xterm. If the ExitOnForwardFailure configuration option is set to =E2=80=9Cyes=E2=80=9D, then a client started with -f will wait for all remote port for=E2=80=90 wards to be successfully established before placing itself in the background. -- R. Kevin Oberman, Network Engineer, Retired E-mail: rkoberman@gmail.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAN6yY1tuewKkL-%2BAVAgmX-b3Lo7edR6wFxOO3zyeH4S6BjjqzA>