Bottom Line: It is 100% safe to truncate or compress old Apache log files. Clearing error.log and access.log archives will NOT bring down your Apache web server or affect hosted websites.
What are Apache Error & Access Logs?
Located at /var/log/apache2/ on Ubuntu/Debian (or /var/log/httpd/ on RHEL/CentOS), these text files are generated by the Apache HTTP Server.
Apache writes:
access.log: Plain-text lines recording every HTTP request (IP address, user agent, requested URL, response status code).error.log: PHP errors, SSL handshake failures, and rewrite rule warnings.
On high-traffic Linux servers or sites targeted by web scrapers, Apache log files expand exponentially, growing to 10 GB to 50 GB+ and crashing servers due to full root partitions.
Can You Delete Apache Logs?
✅ Yes, it is safe to truncate.
- No downtime risk: Web sites and virtual hosts stay 100% online.
- Safety rule: Truncate log files using
>orlogrotaterather thanrmso Apache doesn’t lose its open file descriptor.
How to Safely Clean Up Apache Logs
Method 1: Truncate Logs safely (Without Restarting Apache)
sudo truncate -s 0 /var/log/apache2/access.log
sudo truncate -s 0 /var/log/apache2/error.log
Method 2: Compress Old Logs with Logrotate
To enable automatic daily compression and deletion of 14-day-old logs, verify /etc/logrotate.d/apache2:
/var/log/apache2/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
}
Related Guides
- Learn about deleting Nginx proxy cache.
- How to clean up Linux /var/log.
- Check if you can clean journalctl logs.
Discussion
Loading authentication...