To rotate your nginx log files, you can use the log file handler provided by FreeBSD: newsyslog.
Configuring /etc/newsyslog.conf
/var/log/nginx-access.log 644 7 1024 * JC /var/run/nginx.pid /var/log/nginx-error.log 644 7 1024 * JC /var/run/nginx.pid
Before log rotation:
-rw-r--r-- 1 root wheel 104278002 Jul 16 11:35 nginx-access.log -rw-r--r-- 1 root wheel 1509531 Jul 16 11:17 nginx-error.log
After log rotation:
-rw-r--r-- 1 root wheel 967 Jul 16 12:42 nginx-access.log -rw-r--r-- 1 root wheel 5310443 Jul 16 12:41 nginx-access.log.0.bz2 -rw-r--r-- 1 root wheel 77 Jul 16 12:41 nginx-error.log -rw-r--r-- 1 root wheel 37552 Jul 16 12:41 nginx-error.log.0.bz2
Pingback: FreeBSDのログローテーションをnewsyslogに移行した | Kitchen Garden Blog @hfm()