Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail2ban and logrotations #1903

Closed
1 of 3 tasks
StephenAtty opened this issue Oct 1, 2017 · 1 comment
Closed
1 of 3 tasks

Fail2ban and logrotations #1903

StephenAtty opened this issue Oct 1, 2017 · 1 comment

Comments

@StephenAtty
Copy link

StephenAtty commented Oct 1, 2017

Environment:

  • Fail2Ban version (including any possible distribution suffixes): Fail2Ban v0.11.0.dev0
  • OS, including release name/version: Ubuntu 14.04.5 LTS
  • Fail2Ban installed via OS/distribution mechanisms
  • You have not applied any additional foreign patches to the codebase
  • Some customizations were done to the configuration (provide details below is so)

The issue:

Fail2ban writes into /var/log/fail2ban.log
Log rotate runs and changes the log files so that the old log is fail2ban.log.1
and the current log should be fail2ban.log

What seems to be happening is that logrotate changes the filename to fail2ban.log.1 but fail2ban continues to write into that log rather than using the new one...

-rw-r----- 1 root      adm             0 Oct  1 06:28 fail2ban.log
-rw-r--r-- 1 root      root        67859 Oct  1 12:59 fail2ban.log.1

Here is my logrotate configuration

/var/log/fail2ban.log {

    weekly
    rotate 4
    compress

    delaycompress
    missingok
    postrotate
        fail2ban-client set logtarget /var/log/fail2ban.log >/dev/null
    endscript

    # If fail2ban runs as non-root it still needs to have write access
    # to logfiles.
    # create 640 fail2ban adm
    create 640 root adm
}

@sebres
Copy link
Contributor

sebres commented Oct 2, 2017

Please take a look in our rotate-script:
https://github.com/fail2ban/fail2ban/blob/0.11/files/fail2ban-logrotate#L12

I assume following will help:

postrotate
-        fail2ban-client set logtarget /var/log/fail2ban.log >/dev/null
+        fail2ban-client flushlogs >/dev/null || true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants