import os
with open('logfile.txt', 'rb') as f:
f.seek(-2, os.SEEK_END)
while f.read(1) != b'\n':
f.seek(-2, os.SEEK_CUR)
print(f.readline().decode())
출처: https://www.quora.com/How-can-I-read-the-last-line-from-a-log-file-in-Python
'linux' 카테고리의 다른 글
fix invalid argument to attribute "__mode__"" error (0) | 2019.04.17 |
---|---|
running valgrind on gentoo (0) | 2019.03.13 |
vivado execution through rofi (0) | 2019.01.31 |
ubuntu 설정들 (0) | 2019.01.21 |
xserver error fix after gentoo system upgrade (0) | 2019.01.09 |