Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does fail2ban continue to monitor rotated log files?

For example, I have a rule monitoring /var/log/fail2ban.log which is automatically rotated by the system every week (7 days). I want to have a rule that monitors for banned IPs in that log to find repeat offenders that have been banned 5 times in the last 10 days. Is that possible?

share|improve this question
up vote 3 down vote accepted

Yes, fail2ban continues to monitor rotated log files. From server/

439 ##
440 # FileContainer class.
441 #
442 # This class manages a file handler and takes care of log rotation detection.
443 # In order to detect log rotation, the hash (MD5) of the first line of the file
444 # is computed and compared to the previous hash of this line.
share|improve this answer

The above answer is incorrect with regards to your question. FileContainer only uses file log rotation detection to reset log reading back to the start of the file instead of the standard procedure of continuing from the last offset:

class FileContainer:
       def open(self):
                self.__handler = open(self.__filename, 'rb')
                # Compare hash and inode
                if self.__hash != myHash or self.__ino != stats.st_ino:
              "Log rotation detected for %s" % self.__filename)
                        self.__hash = myHash
                        self.__ino = stats.st_ino
                        self.__pos = 0
                # Sets the file pointer to the last position.

There is no code in there that goes looking for rotated files to also parse through.

share|improve this answer
One can specify multiple logs in one of two ways (or a combination). You can use file globs (wildcards) to match log files to monitor (i.e.logpath = /var/log/*somefile.log) or a list of logfiles to monitor, separated by whitespace (spaces, tabs, newlines) such as logpath = /var/log/auth.log /var/log/auth.log.1. – Troy Morehouse Dec 29 '15 at 20:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.