I tried the solution in this answer, since the file I'm tailing can grow large than 50GB, the server is choking. Any suggestions on how to follow it without storing all in memory?
Asked
Active
Viewed 42 times
-1
-
1Which solution? None were accepted. Show your code – Iain Shelvington Dec 29 '21 at 04:23
-
load file in chunck ? – sahasrara62 Dec 29 '21 at 04:49
1 Answers
0
You don't need an external app.
import time
fsl = open('/var/syslog')
# Seek to end
fsl.seek(0,2)
last = fsl.tell()
# Back up 200 bytes
fsl.seek( last-200 )
while True:
print( fsl.read() )
time.sleep(5)
Now, this will print an extra linefeed every time it tries to get more data, but you can fix that.

Tim Roberts
- 48,973
- 4
- 21
- 30