bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: && operator prevents backgrounding over ssh


From: Geir Hauge
Subject: Re: && operator prevents backgrounding over ssh
Date: Thu, 26 Sep 2013 17:44:15 +0200

2013/9/26 Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>

> 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 &"
>
> The above command will wait for sleep(1) to finish before returning.
> If it is run without ssh, it returns immediately. Furthermore, other
> shells such as dash and zsh will return immediately regardless of
> whether ssh is used.
>

Probably because it's equivalent to

  { cd /tmp && nohup sleep 10 >/dev/null 2>&1; } &

so the backgrounded process still have stdout and stderr connected to ssh.
This should do what you want:

  cd /tmp && { nohup sleep 10 >/dev/null 2>&2 & }

-- 
Geir Hauge


reply via email to

[Prev in Thread] Current Thread [Next in Thread]