# Logrotate Configuration Files: # # - /usr/sbin/logrotate The logrotate executable # # - /etc/cron.daily/logrotate This shell script executes the logrotate # command # # - /etc/logrotate.conf Log rotation configuration for all the log # files are specified in this file. # # - /etc/logrotate.d When individual packages are installed on # the system, they drop the log rotation # configuration information in this # directory # Sample /etc/logrotate.conf that rotates a logfile for every 1KB. # /tmp/output.log { # runs only if the filesize is greater than or equal to this size size 1k # rotate the original file and create the new file with the specified # permission, user and group. create 700 bala bala # limits the number of log file rotation. So, this would keep only the # recent 4 rotated log files. rotate 4 } # To continue to write the log information in the newly created file AFTER # rotating the old logfile, use this configuration: /tmp/output.log { size 1k # create the copy of the original file and # truncates the original file to zero byte size copytruncate rotate 4 } # Run the logrotate command, the -s option specifies the filename to write the # logrotate status to: logrotate -s /var/log/logstatus logrotate.conf # Compress the rotated log files /tmp/output.log { size 1k copytruncate create 700 bala bala rotate 4 compress } # Logrotate dateext option: Rotate the old log file with date in the log filename /tmp/output.log { size 1k copytruncate create 700 bala bala dateext rotate 4 compress } # Rotate the log file weekly/daily/monthly /tmp/output.log { monthly copytruncate rotate 4 compress } # Run custom shell scripts immediately after log rotation /tmp/output.log { size 1k copytruncate rotate 4 compress postrotate /home/bala/myscript.sh endscript } # indicates that the rotated log files would be removed after 100 days. /tmp/output.log { size 1k copytruncate rotate 4 compress maxage 100 missingok } # default usage logrotate /etc/logrotate.conf