Differences

This shows you the differences between two versions of the page.

Link to this comparison view

logrotate [2014/10/07 14:06]
logrotate [2014/10/07 14:06] (current)
Line 1: Line 1:
 +====== Rotating System Logs ======
  
 +  * [[rsyslog]]
 +
 +=== Configuration Options ===
 +
 +  * **create <​mode>​ <​owner>​ <​group>​** - permissions
 +  * **dateext** - append the date to the extension instead of a number -- default is ''​-YYYYMMDD''​
 +  * **ifempty** - rotate the log even if the file is empty **(default)**
 +  * **maxage <​count>​** - remove rotated logs older than ''<​count>''​ days
 +  * **missingok** - if the log file is missing, go ahead to the next one -- by default, ''​nomissingok''​ is set
 +  * **rotate <​count>​** - log files are rotated ''<​count>''​ times before being removed
 +
 +=== PHP error log ===
 +
 +<​code>​
 +/​var/​log/​php_error.log {
 +# compress old logs with gzip
 +compress
 +
 +# zero out the old file instead of creating a new one
 +# this is simpler than setting the permissions in the config file
 +copytruncate
 +
 +# create a new log file immediately after rotation and use these
 +# permissions if you want
 +# create 664 root www-logs
 +
 +# If the log file is missing, go on to the next one without issuing an error message
 +missingok
 +
 +# Do not rotate the log if it is empty
 +notifempty
 +}
 +</​code>​
 +
 +=== Postfix Logrotate ===
 +
 +See http://​www.question-defense.com/​2010/​01/​10/​postfix-logrotate-script-for-gentoo-linux
 +
 +I prefer to run ours daily.
 +
 +<​code>​
 +/​var/​log/​mail.* {
 +  missingok
 +  notifempty
 +  weekly
 +  rotate 3
 +  compress
 +  sharedscripts
 +  postrotate
 +    /​etc/​init.d/​postfix reload > /dev/null 2>&1 || true
 +  endscript
 +}
 +</​code>​
 +
 +For stats:
 +
 +<​code>#​ pflogsumm.pl -d today /​var/​log/​mail.log</​code>​
 +
 +=== NetBSD ===
 +
 +  * [[NetBSD]]
 +
 +<​code>​
 +1/ modify /​usr/​pkg/​etc/​logrotate.conf to your needs,
 +or better, add your own configuration files in
 +/​usr/​pkg/​etc/​logrotate.d/​
 +
 +2/ set up a daily cron job for logrotate in root's crontab;
 +this can be done with one of the following line:
 +0 0 * * * /bin/sh /​usr/​pkg/​share/​examples/​logrotate/​logrotate.cron
 +0 0 * * * /​usr/​pkg/​bin/​logrotate /​usr/​pkg/​etc/​logrotate.conf
 +</​code>​
 +
 +=== netatalk ===
 +
 +  * [[netatalk]]
 +
 +Any options will work, but ''​copytruncate''​ is necessary so that logs are continually written to.
 +
 +<​code>​
 +/​var/​log/​netatalk.log {
 +        notifempty
 +        maxage 31
 +        missingok
 +        rotate 7
 +        copytruncate
 +}
 +</​code>​