Answer the question
In order to leave comments, you need to log in
How to run a task in the background on Debian and only write the last line of the console to a file?
I need to run a python3 script in the background and write the contents of the console to a file to be able to control the execution, but in this case it quickly fills the file, since it transfers a lot of data to the network and to the console, how to make it always log did the file write only the last line, and did not accumulate the full contents from the moment it was launched?
/usr/bin/python3 test.py >> test.log &
Answer the question
In order to leave comments, you need to log in
/usr/bin/python3 test.py | tail -n1 >> test.log &
Another option is to cut off the excess using grep
I need that at the time of opening, I saw in the test.log file, for example, only 5, or 255, depending on how long it worked
how to make it so that it always writes only the last line to the log file, and does not save the full contents from the moment it was launched?
there are about 50-60 iterations per second, so many times in the script itself, saving is not very relevant, probably
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question