Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So there's the usual way of pausing commands with CTRL+Z and you can then do "bg 1" or whatnot to resume the command, and that works just fine.

What if I started a command that sends a bunch of output to stdout, but I don't want to see that stuff anymore after "unpausing" the command. Could I do something similar to "bg 1 > file.log"?

share|improve this question

This is based on this answer which has instructions for sending output to /dev/null.

To send output of a running program to /tmp/file.log, for example, do the following:

From a second terminal, use ps to get the process ID of your program.

Type touch /tmp/file.log to create an empty file for your output to go into.

Type gdb -p [PID] using the process ID from ps.

At the (gdb) prompt type these commands:

p dup2(open("/tmp/file.log",1),1)
p dup2(open("/tmp/file.log",1),2)

In response to the dup2 commands, you should see "$1 = 1" and "$2 = 2". You should see output cease on the other terminal and you should be able to cat or tail -f the log file (or use ls -l repeatedly and see the size increase).

Now you can suspend your process using Ctrl-Z and resume it in the background using bg 1 (or whatever the job number happens to be).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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