#!/usr/bin/python3 import sys import os import re from pygtail import Pygtail log_file = '/var/log/auth.log' offset_file = os.path.join(os.getenv("HOME"),"data", os.path.basename(sys.argv[0]) + "." + os.path.basename(log_file) + ".offset" ) for line in Pygtail(log_file, offset_file=offset_file): if not re.search('CRON',line) and \ not re.search('Connection closed',line): sys.stdout.write(line)