Bash – redirecting output of running background job in bash

background-processbashio-redirectionoutput

in bash I have some jobs running, in background. They are always producing random irrelevant error messages that pollute the terminal. I am not always so prompt to start them with the 2>&1 > /dev/null redirect. How can I redirect the output when they are already running?

Best Answer

Bash can't modify the file descriptors of a running process.

See answers for How to change the output redirection of a running process? (or a similar thread on stackoverflow)

The easiest and only current tool seems to be reredirect:

reredirect is a utility for taking an existing running program and attaching its outputs (standard output and error output) to files or another process. (quoting project homepage)

reredirect -m /dev/null <PID>
Related Question