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?
If you don't want that one function to print, call blockPrint() before it, and enablePrint() when you want it to continue. If you want to disable all printing, start blocking at the top of the file.
The short answer is to use nohup python -u args... to force python to print and flush buffer for each print() call. I believe this is due to Python's default behaviour to write to buffer first, but nohup doesn't trigger the buffer to be cleared.
it will delete the contents of the file but not the file. It shouldn't. most probably nohup file is corrupted.
The nohup command only writes to nohup. out if the output is otherwise to the terminal. If you redirect the output of the command somewhere else - including /dev/null - that's where it goes instead.
You can use
nohup python -u python_script.py &
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With