Hinrik Örn Sigurðsson wrote: > The "&&" operator in bash seems to inhibit backgrounding when run over > ssh. You can try it with the following: > > ssh localhost "cd /tmp && nohup sleep 10 >/dev/null 2>&1 &"
Just a reminder that ssh reads from stdin unless explicitly told to avoid reading from stdin. If stdin isn't going to be used then the -n option should be used. -n Redirects stdin from /dev/null (actually, prevents reading from stdin). This must be used when ssh is run in the background. A common trick is to use this to run X11 programs on a remote machine. For example, ssh -n shadows.cs.hut.fi emacs & will start an emacs on shadows.cs.hut.fi, and the X11 connection will be automatically forwarded over an encrypted channel. The ssh program will be put in the background. (This does not work if ssh needs to ask for a password or passphrase; see also the -f option.) Regardless of the resolution of the above question about bash the usage of ssh in the above should use 'ssh -n'. Bob