Why bash sometimes fails to output python program output to a file

I have a crontab job calling a python script and outputting a file:

python run.py &> current_date.log

now sometimes when i do

tail -f current_date.log

I see that the file is populated with exit, but in other cases the log file exists, but remains empty for a long time. I am sure that the python script prints the material immediately after its launch, and the log file - . Any ideas why it stays empty for a while?

+5
source share
2 answers

Python , , tty, . script python -u .

$ python -h

...

-u     : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
         see man page for details on internal buffering relating to '-u'

...
+12

Python ( bash) . Python . python -u, .

- ( ), flush() .

+8

All Articles