I have a python program main.py which produces some outputs which I would like to write to a file. I want to execute the program non-blocking. Usually I would use python2.7 main.py > main.out & or nohup python2.7 main.py &> main.out &.
My problem is, that the program may run very long, and I want to have access to the output created so far before the program terminates. When I execute python2.7 main.py > main.out and I then stop the program with Ctrl-C the output file has the output created so far. However, with the nonblocking commands, the output-file remains empty during execution, and after I kill the program.
How do I do this?