One admin task on my server that I had long procrastinated was to set up rotation of apache logs. I noticed that some of my websites' logs were getting huge — tens to hudreds of megabytes, so today I set up log rotation. It was easier than I expected.
On Debian, log management is done by the program logrotate. Logrotate is
run daily by a cron job in
/etc/cron.daily/logrotate. Adding a log
rotation job to logrotate is as simple as adding a config file to
In my case, I wanted to rotate the apache logs of my websites, which live
/srv/. To create my logrotate config, I copied the apache one:
cp /etc/logrotate.d/apache /etc/logrotate.d/jjf-websites
Then I changed the pathname in the new file from
/srv/*/logs/*.log, and tested it:
logrotate -f /etc/logrotate.d/jjf-websites
What could be easier?