Skip to content
Advertisement

Preventing background process from writing to console

In Linux’s bash, I know how to start a long running process and send it to the background.

For example run.sh, then press Control+Z, then type bg 1

Sometime I would like to continue do other work, but this background process keep printing to my Putty console – which is annoying.

I know I can start the run.sh &> /tmp/run.sh.log thus pumping all output to /tmp/run.sh.log but sometime I just forgot to do so.

How do I stop that background process from printing to my console?

Advertisement

Answer

If you have started the process already and want to stop it from printing to stdout, while still keeping it running, you may use:

stty tostop

When you give stty the tostop argument it stops the background processes that try to write to stdout

To enable the process to write again you may use fg.

Original source can be found here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement