top of page

Log Rotate

recently have come across with the logrotate functionality in the linux box which help to delete the logs in the setting we provide.

logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.

Few of the Log Rotate commands that we hope will be helpful,

 

/var/log/messages { rotate 5 weekly postrotate /usr/bin/killall -HUP syslogd endscript }

 

/var/log/httpd/access.log" /var/log/httpd/error.log { rotate 5 mail www [at] my.org <--- We can provide the email ID for the logs to be sent size 100k <-- Filter criteria is in the Size over here sharedscripts postrotate /usr/bin/killall -HUP httpd endscript }

 

If there are amy files

/var/log/httpd/access.log" /var/log/httpd/*log* { <-- For all the logs under it. rotate 5 mail www [at] my.org <--- We can provide the email ID for the logs to be sent size 100k <-- Filter criteria is in the Size over here

compress endscript }

 

Wrong Logrotate

/var/log/messages { <-- Over here we have used two criteria rotate 5 1. Weekly weekly 2. Size

size 100k This will give us a wrong result} postrotate /usr/bin/killall -HUP syslogd endscript }

 

bottom of page