• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

How to rotate /var/log/httpd/access_log ?

A

AlterEgo

Guest
Can someone explain me how i can rotate the access_log in /var/log/httpd/access_log ? It's realy huge (about 5 gig a day) and i realy don't need it !

Thanks!
 
create /etc/logrotate.d/httpd with the following. If will likely fail on that 5 gig log though. If you dont need it, I would stop apache, delete it, and restart apache.
/var/log/httpd/*log {
missingok
notifempty
daily
rotate 5
compress
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}
 
Thanks, wil first try a new httpd... i think your 2nd solution will not work because it will recreate access_log automatic.
 
That's what it is supposed to do. Apache will not run without the access_log. It is defined in your httpd.conf.
 
You can always empty it with an hourly cron with somehting like

0 * * * * /bin/echo "" > /path/to/access_log

(may need to use \"\" cant remember)


seems strange for that log to be getting so large daily if its already set on rotation
 
Wow, if his site is that busy, I wanna visit it too!!! lol
 
Originally posted by mikk
You can always empty it with an hourly cron with somehting like

0 * * * * /bin/echo "" > /path/to/access_log

(may need to use \"\" cant remember)


seems strange for that log to be getting so large daily if its already set on rotation

Thanks that's also a good solution!
 
Originally posted by jamesyeeoc
Wow, if his site is that busy, I wanna visit it too!!! lol

Please send me a private message if you want to visit this site ! ;)
 
Back
Top