Logrotate
Logrotate is an amazing tool for linux admins. It is service called by cron in the daily cron job. Logrotate gives you options on how you want to manage any log file.
- Archive
- Compress
- Reset
- etc.
To configure logrotate for specific log files from Apache, tomcat, subversion, hudson, etc.
- Go to /etc/logrotate.d
- Create seperate configuration files for each application’s log file
- /var/log/http/* { create 0640 apache apache #This line defines who is going to own the new log file after the old one is archived and compressed missingok daily # Run this daily rotate 7 # Rotate logs every 7 days, from line above compress # Compress log files }
- Save and check. To test “logrotate -f /etc/logrotate.d/filename”