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?

  • See this related answer: unix.stackexchange.com/a/4035/74516 (not tested).
    – vinc17
    Nov 30, 2014 at 1:19
  • 1
    Thanks. Actually this command solved my problem in the most straightforward way: github.com/jerome-pouiller/reredirect
    – fstab
    Nov 30, 2014 at 1:31
  • @fstab You can write that as an answer to your own question. I know I didn't know it was possible to do this (attaching to the target program as a debugger is quite a nice hack!), so I thank you for mentioning it.
    – Celada
    Nov 30, 2014 at 4:07

1 Answer 1


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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.