Reputation: 2451
Im new to python and web development, I have a basic issue I believe.
I'm running my server with pyramid, and I use nohup.out to write output to a file.
nohup ../bin/pserve development.ini
When I do tail -f nohup.out
I can see all the output coming from the logging.info()
calls in my code.
but I don't see all the output from the print()
calls.
what is the reason for that, and how can I set it that I will see the print() in the nohup file?
Upvotes: 17
Views: 15348
Reputation: 9061
You can use stdbuf -oL to flush the print statements. Command will look like
nohup stdbuf -oL python python_script.py > nohup.out &
Upvotes: 11
Reputation: 419
Printed output is buffered when not to a terminal. nohup
replaces stdout with a non-terminal (a file, in fact).
In the absence of any code, all I can do is guess, but the most likely answer is that your output is buffered inside the python process, and when that buffer fills it will be flushed to nohup.out
. To see if this is the case, try adding a lot more prints to fill up the buffer faster.
Upvotes: 4