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
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.
© 2024 OneMinuteCode. All rights reserved.