Support #580
Updated by Daniel Curtis almost 10 years ago
This is a simple guide for setting up logrotate on FreeBSD 9.2-RELEASE.
* Update the system and ports tree:
<pre>
pkg update && pkg upgrade
portsnap fetch extract
</pre>
* Install logrotate:
<pre>
pkg install logrotate
</pre>
* Edit the logrotate config file:
<pre>
vi /usr/local/etc/logrotate.conf
</pre>
#* Add/modify the following:
<pre>
/var/log/httpd-access_log {
daily
size 1024k
rotate 30
copytruncate
compress
notifempty
missingok
}
/var/log/httpd-error_log {
daily
size 1024k
rotate 30
copytruncate
compress
notifempty
missingok
}
</pre>
* Test logrotate:
<pre>
logrotate -d /usr/local/etc/logrotate.conf
</pre>
* Setup a cronjob to run logrotate:
<pre>
crontab -e
</pre>
#* And add the following:
<pre>
## Logrotate at 1 AM in the morning
0 01 * * * root /usr/local/sbin/logrotate /usr/local/etc/logrotate.conf > /dev/null 2>&1
</pre>
* Restart cron:
<pre>
service cron restart
</pre>
h2. Resources
* https://www.freebsd.org/cgi/man.cgi?query=logrotate&manpath=SuSE+Linux/i386+11.3
* https://teklimbu.wordpress.com/2007/10/16/managing-your-linuxunix-log-files-using-logrotate/
* http://www.thegeekstuff.com/2010/07/logrotate-examples/