4

Nginx occupies all the available disk space. How to set limit for log files on Mac OS?

2 Answers 2

6

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.

3
  • Thank you for your answer! :)
    – Max Lipsky
    Commented Oct 7, 2015 at 15:44
  • 1
    shoudn'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?
    – Paolo
    Commented 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
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.