UNIX - Logrotate - Quick Guide

UNIX / Linux - General UNIX

Logrotate, when run uses the /etc/logrotate.conf file by the logrotate script (which is found in the /etc/cron.daily /weekly ).

  • /etc/crontab - dictates when the crons run (at which times , dates).
  • /etc/cron.daily/weekly - contains the logrotate script when runs the logrotate command and.conf file.

An example logrotate.conf file,

root@bigdaddy# vim /etc/logrotate.conf
/var/log/local2.log {

rotate 5
daily
compress
create
missingok

#Close and open syslogd files after rotating logs
postrotate
kill -HUP `cat /var/run/syslogd.pid`
endscript
}

Note : You shouldnt use wildcard characters (i.e *) as this can cause you to log rotate already rotated logs.

For troubleshooting you can run the command directly using the force and verbose options to see exactley what is happening,

/usr/sbin/logrotate /etc/logrotate.conf -fv

 

2 great links can be found at,

 

Article updates via email..


We have 31 guests online

Related Articles