Nginx occupies all the available disk space. How to set limit for log files on Mac OS?
2 Answers
Rotate the log files. On OS X, newsyslog
is the preferred utility to do that. Set up a file like this in /etc/newsyslog.d/nginx.conf
:
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/nginx.log deceze:wheel 644 2 1024 * J
Read https://www.newsyslog.org/manual.html for more information.
-
-
1shoudn't a
SIGUSR1
signal be sent to the nginx master process? Or this can be skipped because the log file is not deleted but set to empty?– PaoloCommented Mar 27, 2017 at 14:42 -
@Paolo Good point, I cannot actually answer that with certainty. You probably should.– deceze ♦Commented Mar 27, 2017 at 14:53
Building on @deceze's answer, here's an adapted version of Apple's Apache configuration for a Homebrew-installed nginx
:
#logfilename [owner:group] mode count size when [flags] [/pid_file] [sig_num]
/opt/homebrew/var/log/nginx/access.log _nginx:_nginx 644 10 20480 * Z /opt/homebrew/var/run/nginx.pid 30
This is assuming you're running as user:group _nginx:_nginx
. It sends the correct SIGUSR1
signal (30 on macOS) to nginx
. Also changed to using gzip
instead of bzip2
.