$ python some_script.py | tee log.$(date +%s).txt
Problem
The problem is that althoug I get all the output on the console it appers to be bufffered and I can't monitor the logs in live when my script runs. An example code can be seen below.
Solution
You have to tell python to stop buffering the data sent the the stream you are using (stdin, stdout, stderr). On on the way I found convenient is by using the command line '-u' options.
References
- http://stackoverflow.com/questions/107705/python-output-buffering
- http://stackoverflow.com/questions/3515757/python-print-statements-being-buffered-with-output-redirection
- http://www.pixelbeat.org/programming/stdio_buffering/
No comments:
Post a Comment