3

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?

3 Answers 3

3

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

3

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'
1

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.
1

You must log in to answer this question.

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