I have a simple python file on a Linux VM
import time
while True:
print("test")
time.sleep(10)
which I start with
python test.py > test.log
but even after a longer time that file is empty
-rwxrwx--- 1 root vboxsf 0 Sep 29 07:57 test.log
Is the output cached or something? How can I make the output to go into the file right away?
I am pretty sure I forgot something very easy…
>Solution :
change print like below
print("test", flush=True)