My issue is that I have a function call it function1 which runs indefinitely. The function itself echo's "hello" every 1 second. Using the command:
function1 >> temp.txt
Every 1 second if I am to view the file temp.txt I should see a new line with "hello". However what's happening is that the function doesn't write to the file until its finished running. Therefore if I am to kill the function nothing will be written. Does anyone know of something I can do in this situation that will basically dynamically update temp.txt?
I have a python script set up the following way:
Therefore this will always be running. Now I call this in a bash script
python pythonscript.py >> temp.txt
kill the process no data is logged.