Linux Python Run Results Live File Output

Asked 2 years ago, Updated 2 years ago, 137 views

To save the result of python execution in crontab as a file and leave it as a log

1 */8 * * * python3 code.py >> ~/log.txt

is in use, but when used in this way, it seems to be logged at once after the entire program has finished running. Is there a way to record the output results in real time?

linux crontab python

2022-09-21 12:37

1 Answers

https://stackoverflow.com/questions/230751/how-to-flush-output-of-print-function

If you are using the print statement (and using Python 3), you can give the flush=True factor.


2022-09-21 12:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.