They are both right and both said what I try to write here. You have enable auto flush as links mention. Also as links mentions
```Usually people remember to set STDOUT as auto-flush, but you should enable this for STDERR as well, or else your messages to STDERR may not appear in your log file immediately, if you are redirecting STDERR to a file.```
tricky part here is that you after flush call exit 0 ( except quick verbose message ) and exit automatic flush all buffers. So if your goal is to get immediatelly messages from this script that you run on background, then you need to enable auto flush ( or disable buffering depends which way you look on it ) you must place it at top of script and not on bottom before end.