1

I have a Python script running on a Linux machine which is printing output out to the terminal. Currently, I'm logging this output to a file using the script command. However, the problem with this approach is that I am not able to read the data added to the file while the script is running; I want to periodically scp this file onto my local machine to read.

Is there any way I can redirect the output of my script such that file is being appended to and closed after every line is printed?

Thanks.

0

After some searching, I found the solution to my problem:

stdbuf -oL python script.py >> log.txt

This does exactly what I wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.