Currently i have this piece of code, but it reads all lines, and then watch the file with the while True statement:
with open('/var/log/logfile.log') as f:
while True:
line = f.readline()
if not line:
time.sleep(1)
else:
print(line)
I actually only need new lines coming after the lines already detected when opening the file - anybody who can help me out? Maybe a better way to watch it aswell, than with the while statement?
Another problem is that on Linux machines the script is actually locking the file so it can not be written to, before i close the script again. On OS X it works fine. Could also be nice with an idea to work around this.
Hope there is somebody out there who have been working with something similar.