Safe to Delete

Apache HTTP Server Error & Access Logs (/var/log/apache2)

Quick Answer: Apache error.log and access.log store web server visitor logs. Truncating old Apache logs is safe and reclaims lost server storage.

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 > or logrotate rather than rm so 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
}

Discussion

Loading authentication...

Related in linux

Linux Audit Framework Log Directory (/var/log/audit)

The Linux auditd service records security events, file access traces, and user commands in /var/log/audit. Learn how to clean auditd log files safely.

Safe to Delete

Fail2ban Ban History Database (/var/lib/fail2ban/fail2ban.sqlite3)

Fail2ban intrusion prevention daemon logs banned IP addresses and SSH brute-force attempts in fail2ban.sqlite3. Clearing Fail2ban database is safe.

Safe to Delete

GNOME Desktop File Indexer Database (~/.local/share/tracker/data)

GNOME Tracker caches desktop search index databases. Resetting the tracker database is safe.

Safe to Delete
Back to all files