D
D
DVoropaev2019-08-06 10:48:27
linux
DVoropaev, 2019-08-06 10:48:27

How to parse /var/log/syslog in realtime in python?

It is necessary to process each new line from /var/log/syslog in a loop. How to do it correctly?
One more thing about log rotation is of interest: every day the syslog file is transferred to syslog.1, and new logs are written to a clean syslog. How to make the script "not broken" at this moment

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xotkot, 2019-08-06
@DVoropaev

for bash use tail but just add the --follow switch with the name parameter which will bind to the name and not the file descriptor:
tail --follow=name TestFile | обработчик

P
paran0id, 2019-08-15
@paran0id

Is it the file that needs to be parsed? I would consider getting logs via journalctl.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question