Super User is a question and answer site for computer enthusiasts and power users. 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

I'm having a php-cli script that is running (detached) in the background.

Is there a way to attach to it's Stdout/Stderr in order to see the output of the application?

share|improve this question
up vote 3 down vote accepted

You can probably do this with gdb. I wrote about the process in an answer to a vaguely-related question.

share|improve this answer

I like using strace it's abit less intimidating than GDB.

strace -s 100000 -e write=1  -e trace=write -p $PID 2>&1 | \
   sed 's/^write(1, //;t;d'
share|improve this answer

dupx is the complete solution which implements what @quack is refering to:

Dupx is a simple utility to remap files of an already running program. Shells like Bash allow easy input/output/error redirection at the time the program is started using >, /tmp/stdout will redirect output of echo to /tmp/stdout. Standard shells however do not provide the capability of remapping (redirecting) of output (or input, or error) for an already started process. Dupx tries to address this problem by using dup(2) system call from inside gdb(1). Dupx is currently implemented as a simple shell wrapper around a gdb script.
share|improve this answer
the motivation to reanswer this question came from and and no good results while searching superuser. i found the vaguely-related posts on SU but things could be simpler. – akira Jan 17 '11 at 6:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .