Descubra por que o Apache para de funcionar todos os domingos de manhã

Descubra por que o Apache para de funcionar todos os domingos de manhã

Eu tenho o Apache configurado no Ubuntu 16.04.4 LTS.

Por alguma razão, quase no mesmo horário todos os domingos de manhã, o Apache para de funcionar.

Quando para, corro systemctl status apache2e vejo:

Mar 04 06:25:24 xxxxxx apache2[11178]:  * Stopping Apache httpd web server apache2

Então, de alguma forma, o Apache foi interrompido. Quando está parado, não há nada em /var/log/apache2/error.log. Quando inicio o Apache novamente, vejo:

[Sun Mar 04 09:44:10.875444 2018] [core:warn] [pid 22442:tid 140355746498432] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?

Parece /var/log/syslogque o Apache foi recarregado (também ProFTPD) e depois foi interrompido em 06:25:24:

Mar  4 06:25:11 xxxxxx systemd[1]: Reloading LSB: Apache2 web server.
Mar  4 06:25:11 xxxxxx apache2[11014]:  * Reloading Apache httpd web server apache2
Mar  4 06:25:11 xxxxxx apache2[11014]:  *
Mar  4 06:25:11 xxxxxx systemd[1]: Reloaded LSB: Apache2 web server.
Mar  4 06:25:18 xxxxxx systemd[1]: Stopping LSB: Starts ProFTPD daemon...
Mar  4 06:25:18 xxxxxx proftpd[11083]:  * Stopping ftp server proftpd
Mar  4 06:25:18 xxxxxx proftpd[11083]:    ...done.
Mar  4 06:25:18 xxxxxx systemd[1]: Stopped LSB: Starts ProFTPD daemon.
Mar  4 06:25:18 xxxxxx systemd[1]: Starting LSB: Starts ProFTPD daemon...
Mar  4 06:25:18 xxxxxx proftpd[11094]:  * Starting ftp server proftpd
Mar  4 06:25:18 xxxxxx proftpd[11094]: 2018-03-04 06:25:18,666 xxxxxx proftpd[11104]: mod_dso/0.5: module 'mod_tls.c' already loaded
Mar  4 06:25:18 xxxxxx proftpd[11094]: 2018-03-04 06:25:18,667 xxxxxx proftpd[11104]: mod_dso/0.5: module 'mod_sftp.c' already loaded
Mar  4 06:25:19 xxxxxx proftpd[11094]:    ...done.
Mar  4 06:25:19 xxxxxx systemd[1]: Started LSB: Starts ProFTPD daemon.
Mar  4 06:25:24 xxxxxx apache2[11178]:  * Stopping Apache httpd web server apache2
Mar  4 06:25:24 xxxxxx apache2[11178]:  *

Como descubro por que o Apache para ou qual processo está interrompendo o Apache (por que motivo) para evitar que isso aconteça novamente?

Responder1

O problema foi causado por logrotate, que interrompe o Apache ao girar logs.

O problema foi resolvido editando /etc/logrotate.d/apache2, mudando reloadpara graceful.

Original:

postrotate
            if /etc/init.d/apache2 status > /dev/null ; then \
                /etc/init.d/apache2 reload > /dev/null; \
            fi;
endscript

Editado:

postrotate
            if /etc/init.d/apache2 status > /dev/null ; then \
                /etc/init.d/apache2 graceful > /dev/null; \
            fi;
endscript

informação relacionada