Author Topic: Apache log file too large  (Read 1014 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Apache log file too large
« on: April 25, 2021, 01:12:03 AM »
I found that the apache log file is too large, how to clear the log? how to make the apache log save a file every day by date?

/usr/local/apache/domlogs/mydomain.log-5.1GB
/usr/local/apache/logs/access_log-4.5GB
/usr/local/apache/logs/suphp_log-3.6GB

I changed suphp_log to suphp_log-, and then changed it to suphp_log. Now the modification time of suphp_log has not changed for a long time, indicating that the system no longer uses suphp_log. How do I fix it?
« Last Edit: April 25, 2021, 01:22:47 AM by gailclark80 »

Offline
*
Re: Apache log file too large
« Reply #1 on: April 25, 2021, 12:34:41 PM »
setup logorotate for dom logs and apache logs


/usr/local/apache/domlogs/*.log   /usr/local/apache/logs/*.log  /usr/local/apache/logs/*_log  {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 640 root adm
    sharedscripts
    postrotate
   /bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
        /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
}

thiis will make smaler flies that you can remove after you dont need - keeping last 20-30 days if needed