Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

For the following command:

ssh -t esolve@hostname 'sudo nohup bash -c "ls > log 2>&1 &"'

I always got error information:

       nohup: ignoring input and appending output to `nohup.out'

why does this happend and how to avoid this error information?

Besides, in the following (I use it to enable output to both screen and file),

   stdbuf -o 0 command|& tee logfile

what is the & used for?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

It happens that the command you're running under nohup never writes to stdout or stderr, and that you aren't sending any input to it. But nohup has no way to know that, so it tells you that any input would be discarded and any output would be written to nohup.out.

To avoid this, redirect nohup's stdin, stdout and stderr to /dev/null.

ssh -t esolve@hostname 'sudo nohup bash -c "ls > log 2>&1 &" </dev/null >/dev/null 2>/dev/null'

As for |&, from the bash manual:

The format for a pipeline is

[time [-p]] [!] command1 [ [| or |&] command2 …]

The output of each command in the pipeline is connected via a pipe to the input of the next command. That is, each command reads the previous command’s output. This connection is performed before any redirections specified by the command.

If |& is used, the standard error of command1 is connected to command2’s standard input through the pipe; it is shorthand for 2>&1 |.

This is a bash extension, also present in zsh.

share|improve this answer
it seems to me that when there are output or error information from the command, like ls in my script, the output and error are not written to nohup.out, why? – misteryes May 8 '13 at 23:12
And with your script, there will be no nohup.out generated on the remote host? – misteryes May 8 '13 at 23:12
@misteryes You've redirected ls's stdout and stderr to log. – Gilles May 8 '13 at 23:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.