tags:

views:

394

answers:

2

Normally I would start a command like

longcommand &;

I know you can redirect it by doing something like

longcommand > /dev/null;

for instance to get rid of the output or

longcommand 2>&1 > output.log

to capture output.

But I sometimes forget, and was wondering if there is a way to capture or redirect after the fact.

longcommand
ctrl-z
bg 2>&1 > /dev/null

or something like that so I can continue using the terminal without messages popping up on the terminal.

+2  A: 

Try this link: http://etbe.coker.com.au/2008/02/27/redirecting-output-from-a-running-process/

Always better to copy the gist of it here rather than just linking.
dmckee
The gist: attach to the running process using `gdb`, then do 'p close(1)' and 'p creat("/tmp/foo3", 0600)' to redirect STDOUT, then disconnect gdb while leaving the program running. A clever trick!
cjm
A: 

http://www.isi.edu/~yuri/dupx/

blah