My /var/log/apache2 folder is getting out of hand. It has loads of old compressed error.log files that I want to get rid of before my server runs out of space and explodes.

Firstly - Is it safe to manually delete:

error.log.1 error.log.2.gz ---> error.log.11?

Secondly is there a way to automatically delete these files?


  • 1
    logrotate is your friend. – Chopper3 Apr 11 '13 at 17:02

Yes, it's safe to delete the files though deleting the current file doesn't generally do what you expect.

By default Ubuntu uses logrotate Take a look at your /etc/logrotate.d/apache2 file, you'll probably find that is has a line like

rotate 52

This means it will keep 52 copies of your rotated log files. Change this number to the number you want to keep. This will though work on all the apache2 logs if you want to just do the error log then split it out and give it it's own rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.