IF one were truly wanting that data, I'd suggest attaching the gdb debugger to the python interpreter, momentarily stopping the task, calling
fsync(1) (stdout), detach from it (resuming the process) and go peruse the output file.
/proc/$(pidof python)/fd to see valid file descriptors.
$(pidof x) returns the PID of process named '
# your python script is running merrily over there.... with some PID you've determined.
# load gdb
# attach to python interpreter (use the number returned by $(pidof python))
# force a sync within the program's world (1 = stdout, which is redirected in your example)
# the call SHOULD have returned 0x0, sync successful. If you get 0xffffffff (-1), perhaps that wasn't stdout. 0=stdin, 1=stdout, 2=stderr
# remove our claws from poor python
# we're done!
I've used this method to change working dir's, tweak settings on the fly... many things. Alas, you can only call functions which are defined in the running program,
fsync works nicely though.
(gdb command '
info functions' will list all of the functions available. Be careful though. You're operating LIVE on a process.)
There is also the command
peekfd (found in
psmisc package on Debian Jessie and others) which will allow you to see what's hiding in buffers of a process. Again,
/proc/$(pidof python)/fd will show you valid file descriptors to give as arguments to peekfd.
If you don't remember
-u for python, you can always prefix a command with
coreutils, already installed) to set stdin/stdout/stderr to unbuffered, line buffered or block buffered as desired:
stdbuf -i 0 -o 0 -e 0 python myscript.py > unbuffered.output
man pages are your friends, hey! perhaps an alias might be useful here too.
alias python='python -u'
Now your python always uses
-u for all your command line endeavors!