Quote:
Originally posted by ivj
I run my program using the following command:
nohup sh -c "exec $RUN_CMD >>$NBWA_HOME/log/spider.log" >/dev/null &
And when my program crashed there was no error messages in spider.log. I assume this is because all those message went into the error stream which was the terminal which I couldn't see because it was ran in the background...
How can I forward both standard output and error output into the same file?
Thanks!
|
Because you redirect everything to `/dev/null' at the end of the line.
According to bash manual:
Quote:
...
Redirecting Standard Output and Standard Error
Bash allows both the standard output (file descriptor 1)
and the standard error output (file descriptor 2) to be
redirected to the file whose name is the expansion of word
with this construct.
There are two formats for redirecting standard output and
standard error:
&>word
and
>&word
Of the two forms, the first is preferred. This is seman-
tically equivalent to
>word 2>&1
...
|
Thus, your command should be:
Code:
nohup sh -c "exec $RUN_CMD &>$NBWA_HOME/log/spider.log" &
Hope this help.