Herr Bischoff


How to Properly Rotate Nginx Logs With newsyslog

For people starting out with FreeBSD, this is a bit confusing. Many times you just want a working example and reason your way about how stuff works from there.

The key here is to include the PID file, so newsyslog knows which process to send the respective signal to.

Since FreeBSD has otherwise excellent documentation, be sure to read the man file for pointers about the options you can use in newsyslog config files: man newsyslog.conf

# /usr/local/etc/newsyslog.conf.d/nginx.conf

# logfilename         [owner:group]  mode  count  size  when  flags  [/pid_file] [sig_num]
/var/log/nginx/*.log                 644   30     *     @T00  BCG    /var/run/nginx.pid