毎週日曜日の朝にApacheが停止する理由を知る

毎週日曜日の朝にApacheが停止する理由を知る

Ubuntu 16.04.4 LTS に Apache をセットアップしました。

何らかの理由で、毎週日曜日の朝のほぼ同じ時間に、Apache の実行が停止します。

それが止まったら、走ってsystemctl status apache2見てみます:

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

どういうわけか Apache が停止しました。停止すると、 には何も表示されません/var/log/apache2/error.log。Apache を再度起動すると、次のように表示されます。

[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?

/var/log/syslogApache (ProFTPD も) がリロードされ、次の場所で停止したようです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]:  *

Apache が停止する理由、またはどのプロセスが (どのような理由で) Apache を停止しているかを調べて、再発を防ぐにはどうすればよいですか?

答え1

この問題はlogrotate、ログのローテーション時に Apache を停止する によって発生しました。

を編集して に/etc/logrotate.d/apache2変更することで問題は解決しました。reloadgraceful

オリジナル:

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

編集済み:

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

関連情報