# fail2ban and logrotate

## eruditas

Hello. I have a problem. fail2ban restarts every night @ 3:10 and all bans are cleared at this time. Is there any solution for this? I tried to use search but all i could find is this. But its not clear to me, coz lines in my /etc/init.d/fail2ban differs from ones in the link.

Thanks for you arnswers.  :Smile: 

----------

## hpeters

 *eruditas wrote:*   

> Hello. I have a problem. fail2ban restarts every night @ 3:10 and all bans are cleared at this time. Is there any solution for this? I tried to use search but all i could find is this. But its not clear to me, coz lines in my /etc/init.d/fail2ban differs from ones in the link.
> 
> Thanks for you arnswers. 

 

Modify /etc/logrotate.d/fail2ban not /etc/init.d/fail2ban

https://bugs.gentoo.org/show_bug.cgi?id=301139

In /etc/logrotate.d/fail2ban change:

The line:

/usr/bin/fail2ban-client reload 1>/dev/null || true

Should be changed to:

/usr/bin/fail2ban-client set logtarget /var/log/fail2ban.log 1>/dev/null || true

----------

## eruditas

Thanks  :Smile:  I'll see if it works  :Smile: 

----------

## Killerchronic

I don't feel this is actually worth a new topic as its along the same lines, however why does fail2ban restart every night at 3:10? 

I would like to know when it starts and stops but i dont want it restarting every night unless its for good reason. I get multiple emails each night saying it stopped then the same amount saying it started, is there a way to turn off its auto-restart/reload thing, it never used to do this a year or so ago.

----------

## Hu

The most common cause of early morning restarts is that a logrotate script is trying to move the other program to a new log file.  I do not know if this applies to fail2ban, but it is easy to check.

----------

## Killerchronic

Thanks, i'll look into that, logrotate could be the cause, i dont recall when i installed it on this server but it wasn't during the base install, could well of been around the same time and i never linked the two.

----------

