Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash: redirecting output from a process that's already running? [duplicate]

Possible Duplicate:
Redirect STDERR / STDOUT of a process AFTER it’s been started, using command line?

Is there a way, in Bash, to capture/redirect the output (and stderr?) of a process once it's already running?

like image 301
ocodo Avatar asked Oct 19 '10 00:10

ocodo


People also ask

How do I redirect the output of an already running process?

The way we can redirect the output is by closing the current file descriptor and then reopening it, pointing to the new output. We'll do this using the open and dup2 functions. There are two default outputs in Unix systems, stdout and stderr. stdout is associated with file descriptor 1 and stderr to 2.

How do I redirect standard output to a file?

Redirecting stdout and stderr to a file: The I/O streams can be redirected by putting the n> operator in use, where n is the file descriptor number. For redirecting stdout, we use “1>” and for stderr, “2>” is added as an operator.

How do I redirect a script output?

In Linux, for redirecting output to a file, utilize the ”>” and ”>>” redirection operators or the top command. Redirection allows you to save or redirect the output of a command in another file on your system. You can use it to save the outputs and use them later for different purposes.

Is it possible to redirect output to Dev Null?

In Unix, how do I redirect error messages to /dev/null? You can send output to /dev/null, by using command >/dev/null syntax. However, this will not work when command will use the standard error (FD # 2). So you need to modify >/dev/null as follows to redirect both output and errors to /dev/null.


1 Answers

It is possible using gdb. The question is already answered in this thread.

like image 192
Juho Östman Avatar answered Nov 09 '22 19:11

Juho Östman