It looks like you need to explicitly flush the buffer:
import sys print 'foo' sys.stdout.flush() time.sleep(5) print 'bar' sys.stdout.flush() time.sleep(5)
See Disable output buffering for Python 2 solutions, which are automatically cleared after each print. A.
In your case, since you control the bash file that runs Python, just add -u or set PYTHONUNBUFFERED=1 :
python -u test.py
or
PYTHONUNBUFFERED=1 python test.py
source share