nohup standerd error

hi,

im using nohup command to execute one script.
in the nohup.out im getting standerd output as well as standerd error in it.
i want standerd output and error in nohup.out and only standerd error in error.txt file.

im using command like following
nohup sh test.sh 2>error.txt &

in this case im able to get error in error.txt file but not in nohup.out file

pl help

thanks in advance

In ksh:

nohup sh test.sh > error.txt 2>&1 &

same is not working

i want standerd output and error in nohup.out and only standerd error in error.txt file.

or is there any way to get only error from txt file

That's something pretty difficult to manage since one file descriptor can only write to one file. I don't see how to make it work with tee either, when different data's being written to different files.

Corona is correct.

Once stderr has been redirected somewhere.... that's where it goes.

You ~can~ get both stderr and stdout into the nohup.out like so:

nohup ksh -c "alkhalskdhfalkshdf ; date ; ps -deaf ; echo alshldfh ; aslkdhalskhhflasd " 2>&1

You may try something like this:

{ nohup cmd 2>&1 >&3 3>&- | tee error.txt; } >nohup.out 3>&1

The Z-Shell shell has support for an internal tee mechanism with its
multios option:

nohup cmd 2>error.txt >nohup.out 2>&1