Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to rotate Apache log files [closed]

I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it.
What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?

like image 962
Scott Gottreu Avatar asked Sep 04 '08 15:09

Scott Gottreu


People also ask

What is the service used to rotate log files automatically?

Logrotate is a system utility that manages the automatic rotation and compression of log files.

What is used to rotate log files monthly?

logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large. Normally, logrotate is run as a daily cron job.

How do you tail a rotating log file?

To watch log files that get rotated on a daily base you can use the -F flag to tail command. The tail -F will keep track if new log file being created and will start following the new file instead of the old file.

How do I force rotate var log messages?

If you want to rotate /var/log/syslog it needs to be listed in a logrotate config file somewhere, and you just run logrotate . If it rotated recently, then logrotate -f to force it to do it again. So, you need that in a file, normally either /etc/logrotate. conf or as a file snippet in /etc/logrotate.


1 Answers

Have you looked at logrotate - this is probably the simplest, most widely available and well understood method of achieving this. It is highly configurable and will probably do 90% of what you need.

like image 51
serg10 Avatar answered Sep 22 '22 16:09

serg10