nohup automatically redirects stderr to stdout, but I want to send it to the terminal (it shows progress). How can I do that?
2 Answers
Just redirect it. Take this script, for example which prints a line to stderr and one to stdout:
#!/bin/sh
echo stderr >&2
echo stdout
If I now run that with nohup
and redirect standard error to a file, it works as expected:
$ nohup a.sh 2>er
$ cat er
nohup: ignoring input and appending output to ‘nohup.out’
stderr
Note that it also includes the stderr of nohup
itself since you are redirecting output of the nohup
. You can do the same with stdout:
nohup a.sh > foo
Basically, nohup
only uses nohup.out
when you don't redirect output.
To print stderr to the terminal, you can use process redirection to pass stderr through tee
:
$ nohup a.sh 2> >(tee)
nohup: ignoring input and appending output to ‘nohup.out’
stderr

- 242,166
-
"how to use nohup while still sending stderr to the terminal" – IttayD Jul 01 '15 at 08:18
-
@IttayD whops, true. See updated answer. – terdon Jul 01 '15 at 08:23
-
this will output to stdout – IttayD Jul 02 '15 at 11:46
-
@IttayD yes, that's what you asked for. It prints stderr to the terminal, to stdout. – terdon Jul 02 '15 at 11:48
As nohup
manual states:
NAME
nohup - run a command immune to hangups, with output to a non-tty
It is used to run a command WITHOUT a tty asociated with it, you can end your session and the command will keep running, thus its output is not attached to a tty therefore not being able to show the output there. nohup
creates a file named nohup.out though, you can access that file with tail -f
from any terminal and keep whatching the command's output.

- 4,015