bashstderr

How do I nohup a subprocess spawned from a commandline?


I have a bit complex to explain issue that I have ran into:

  1. I have a long running nohupped process that redirects its stderr into a file.
  2. However, I use a subprocess to stamp the stderr with a timestamp.
  3. The above mentioned subprocess unfortunately is not nohupped (my bad)!
  4. Now, How do I get this subprocess somehow nohupped and get the stderr preserved and keep coming to the file even after I log out. I have to logout of the server.

The commandline in question looks something like this:

$ nohup myscript.sh -op1 val1 -op2 val2 -op3 val3 >mystderr.txt 2> >(while read line; do echo "$(date): ${line}"; done > n100l1800g0.5.err ) < /dev/null &

The above technique of stamping stderr is learned recently right here at stackoverflow.

Thanks in advance for any clue.


Solution

  • The man page for the nohup I have says nohup [ options ] command [arg ...].

    I remember reading someplace that nohup does not process pipelines, which I think is what you have.

    Try remaking your pipeline processes as a script that accept the arguments and it should work.