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?

link|improve this question

feedback

3 Answers

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.

link|improve this answer
feedback

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'
link|improve this answer
feedback

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.
link|improve this answer
the motivation to reanswer this question came from news.ycombinator.com/item?id=2110636 and gist.github.com/782263 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
feedback

Your Answer

 
or
required, but never shown

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