How can I automatically delete old apache error log files?
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.
Related videos on Youtube
Bob Flemming
Updated on September 18, 2022Comments
-
Bob Flemming over 1 year
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?
Thanks!
-
Chopper3 about 11 yearslogrotate is your friend.
-